Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f295da8f
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f295da8f
编写于
11月 29, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Also hash untitled file names
Fixes #15941
上级
d59cfe95
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
20 addition
and
36 deletion
+20
-36
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+1
-5
src/vs/workbench/services/backup/common/backup.ts
src/vs/workbench/services/backup/common/backup.ts
+3
-9
src/vs/workbench/services/backup/node/backupFileService.ts
src/vs/workbench/services/backup/node/backupFileService.ts
+3
-10
src/vs/workbench/services/backup/test/backupFileService.test.ts
.../workbench/services/backup/test/backupFileService.test.ts
+13
-12
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
f295da8f
...
...
@@ -677,11 +677,7 @@ export class TestBackupFileService implements IBackupFileService {
return
TPromise
.
as
(
void
0
);
}
public
getWorkspaceTextFileBackups
():
TPromise
<
URI
[]
>
{
return
TPromise
.
as
([]);
}
public
getWorkspaceUntitledFileBackups
():
TPromise
<
URI
[]
>
{
public
getWorkspaceFileBackups
(
scheme
:
string
):
TPromise
<
URI
[]
>
{
return
TPromise
.
as
([]);
}
...
...
src/vs/workbench/services/backup/common/backup.ts
浏览文件 @
f295da8f
...
...
@@ -57,18 +57,12 @@ export interface IBackupFileService {
backupResource
(
resource
:
Uri
,
content
:
string
,
versionId
?:
number
):
TPromise
<
void
>
;
/**
* Gets a list of
text
file backups for the current workspace.
* Gets a list of file backups for the current workspace.
*
* @param scheme The scheme of the backup.
* @return The list of backups.
*/
getWorkspaceTextFileBackups
():
TPromise
<
Uri
[]
>
;
/**
* Gets a list of untitled backups for the current workspace.
*
* @return The list of backups.
*/
getWorkspaceUntitledFileBackups
():
TPromise
<
Uri
[]
>
;
getWorkspaceFileBackups
(
scheme
:
string
):
TPromise
<
Uri
[]
>
;
/**
* Parses backup raw text content into the content, removing the metadata that is also stored
...
...
src/vs/workbench/services/backup/node/backupFileService.ts
浏览文件 @
f295da8f
...
...
@@ -182,10 +182,10 @@ export class BackupFileService implements IBackupFileService {
});
}
public
getWorkspace
TextFileBackups
(
):
TPromise
<
Uri
[]
>
{
public
getWorkspace
FileBackups
(
scheme
:
string
):
TPromise
<
Uri
[]
>
{
return
this
.
ready
.
then
(
model
=>
{
let
readPromises
:
TPromise
<
Uri
>
[]
=
[];
model
.
getFilesByScheme
(
'
file
'
).
forEach
(
textFile
=>
{
model
.
getFilesByScheme
(
scheme
).
forEach
(
textFile
=>
{
readPromises
.
push
(
new
TPromise
<
Uri
>
((
c
,
e
)
=>
{
readToMatchingString
(
textFile
.
fsPath
,
'
\n
'
,
2000
,
10000
,
(
error
,
result
)
=>
{
if
(
result
===
null
)
{
...
...
@@ -199,12 +199,6 @@ export class BackupFileService implements IBackupFileService {
});
}
public
getWorkspaceUntitledFileBackups
():
TPromise
<
Uri
[]
>
{
return
this
.
ready
.
then
(
model
=>
{
return
model
.
getFilesByScheme
(
'
untitled
'
);
});
}
public
parseBackupContent
(
rawText
:
IRawTextContent
):
string
{
return
rawText
.
value
.
lines
.
slice
(
1
).
join
(
'
\n
'
);
}
...
...
@@ -214,8 +208,7 @@ export class BackupFileService implements IBackupFileService {
return
null
;
}
// Only hash the file path if the file is not untitled
const
backupName
=
resource
.
scheme
===
'
untitled
'
?
resource
.
fsPath
:
crypto
.
createHash
(
'
md5
'
).
update
(
resource
.
fsPath
).
digest
(
'
hex
'
);
const
backupName
=
crypto
.
createHash
(
'
md5
'
).
update
(
resource
.
fsPath
).
digest
(
'
hex
'
);
const
backupPath
=
path
.
join
(
this
.
backupWorkspacePath
,
resource
.
scheme
,
backupName
);
return
Uri
.
file
(
backupPath
);
...
...
src/vs/workbench/services/backup/test/backupFileService.test.ts
浏览文件 @
f295da8f
...
...
@@ -57,7 +57,7 @@ suite('BackupFileService', () => {
const
untitledFile
=
Uri
.
from
({
scheme
:
'
untitled
'
,
path
:
'
Untitled-1
'
});
const
fooBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
file
'
,
crypto
.
createHash
(
'
md5
'
).
update
(
fooFile
.
fsPath
).
digest
(
'
hex
'
));
const
barBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
file
'
,
crypto
.
createHash
(
'
md5
'
).
update
(
barFile
.
fsPath
).
digest
(
'
hex
'
));
const
untitledBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
untitled
'
,
untitledFile
.
fsPath
);
const
untitledBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
untitled
'
,
crypto
.
createHash
(
'
md5
'
).
update
(
untitledFile
.
fsPath
).
digest
(
'
hex
'
)
);
let
service
:
TestBackupFileService
;
...
...
@@ -91,7 +91,8 @@ suite('BackupFileService', () => {
// Format should be: <backupHome>/<workspaceHash>/<scheme>/<filePath>
const
backupResource
=
Uri
.
from
({
scheme
:
'
untitled
'
,
path
:
'
Untitled-1
'
});
const
workspaceHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
workspaceResource
.
fsPath
).
digest
(
'
hex
'
);
const
expectedPath
=
Uri
.
file
(
path
.
join
(
backupHome
,
workspaceHash
,
'
untitled
'
,
backupResource
.
fsPath
)).
fsPath
;
const
filePathHash
=
crypto
.
createHash
(
'
md5
'
).
update
(
backupResource
.
fsPath
).
digest
(
'
hex
'
);
const
expectedPath
=
Uri
.
file
(
path
.
join
(
backupHome
,
workspaceHash
,
'
untitled
'
,
filePathHash
)).
fsPath
;
assert
.
equal
(
service
.
getBackupResource
(
backupResource
).
fsPath
,
expectedPath
);
});
...
...
@@ -172,12 +173,12 @@ suite('BackupFileService', () => {
});
});
test
(
'
getWorkspace
TextFileBackups
- text file
'
,
done
=>
{
test
(
'
getWorkspace
FileBackups("file")
- text file
'
,
done
=>
{
service
.
backupResource
(
fooFile
,
`test`
).
then
(()
=>
{
service
.
getWorkspace
TextFileBackups
(
).
then
(
textFiles
=>
{
service
.
getWorkspace
FileBackups
(
'
file
'
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
.
map
(
f
=>
f
.
fsPath
),
[
fooFile
.
fsPath
]);
service
.
backupResource
(
barFile
,
`test`
).
then
(()
=>
{
service
.
getWorkspace
TextFileBackups
(
).
then
(
textFiles
=>
{
service
.
getWorkspace
FileBackups
(
'
file
'
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
.
map
(
f
=>
f
.
fsPath
),
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
done
();
});
...
...
@@ -186,19 +187,19 @@ suite('BackupFileService', () => {
});
});
test
(
'
getWorkspace
TextFileBackups
- untitled file
'
,
done
=>
{
test
(
'
getWorkspace
FileBackups("file")
- untitled file
'
,
done
=>
{
service
.
backupResource
(
untitledFile
,
`test`
).
then
(()
=>
{
service
.
getWorkspace
TextFileBackups
(
).
then
(
textFiles
=>
{
service
.
getWorkspace
FileBackups
(
'
file
'
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
,
[]);
done
();
});
});
});
test
(
'
getWorkspace
UntitledFileBackups
- text file
'
,
done
=>
{
test
(
'
getWorkspace
FileBackups("untitled")
- text file
'
,
done
=>
{
service
.
backupResource
(
fooFile
,
`test`
).
then
(()
=>
{
service
.
backupResource
(
barFile
,
`test`
).
then
(()
=>
{
service
.
getWorkspace
UntitledFileBackups
(
).
then
(
textFiles
=>
{
service
.
getWorkspace
FileBackups
(
'
untitled
'
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
,
[]);
done
();
});
...
...
@@ -206,10 +207,10 @@ suite('BackupFileService', () => {
});
});
test
(
'
getWorkspace
UntitledFileBackups
- untitled file
'
,
done
=>
{
test
(
'
getWorkspace
FileBackups("untitled")
- untitled file
'
,
done
=>
{
service
.
backupResource
(
untitledFile
,
`test`
).
then
(()
=>
{
service
.
getWorkspace
UntitledFileBackups
(
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
.
map
(
f
=>
f
.
fsPath
),
[
untitledBackupPath
]);
service
.
getWorkspace
FileBackups
(
'
untitled
'
).
then
(
textFiles
=>
{
assert
.
deepEqual
(
textFiles
.
map
(
f
=>
f
.
fsPath
),
[
'
Untitled-1
'
]);
done
();
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录