Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
50318f4d
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,发现更多精彩内容 >>
提交
50318f4d
编写于
11月 09, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests broken from IBackupMainService.loadSync change
上级
8e5f2f13
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
28 deletion
+29
-28
src/vs/code/electron-main/backup.ts
src/vs/code/electron-main/backup.ts
+3
-3
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+1
-1
src/vs/code/test/electron-main/backup.test.ts
src/vs/code/test/electron-main/backup.test.ts
+25
-24
未找到文件。
src/vs/code/electron-main/backup.ts
浏览文件 @
50318f4d
...
...
@@ -24,7 +24,7 @@ export interface IBackupMainService {
*
* @return The set of active workspace backup paths being tracked for restoration.
*/
getWorkspaceBackupPaths
Sync
():
string
[];
getWorkspaceBackupPaths
():
string
[];
/**
* Pushes workspace backup paths to be tracked for restoration.
...
...
@@ -75,7 +75,7 @@ export class BackupService implements IBackupMainService {
this
.
loadSync
();
}
public
getWorkspaceBackupPaths
Sync
():
string
[]
{
public
getWorkspaceBackupPaths
():
string
[]
{
return
this
.
workspacesJsonContent
.
folderWorkspaces
;
}
...
...
@@ -125,7 +125,7 @@ export class BackupService implements IBackupMainService {
return
path
.
join
(
this
.
backupHome
,
workspaceHash
);
}
pr
ivate
loadSync
():
void
{
pr
otected
loadSync
():
void
{
try
{
this
.
workspacesJsonContent
=
JSON
.
parse
(
fs
.
readFileSync
(
this
.
workspacesJsonPath
,
'
utf8
'
).
toString
());
// invalid JSON or permission issue can happen here
}
catch
(
error
)
{
...
...
src/vs/code/electron-main/windows.ts
浏览文件 @
50318f4d
...
...
@@ -369,7 +369,7 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
// Restore any existing backup workspaces
if
(
openConfig
.
restoreBackups
)
{
const
workspacesWithBackups
=
this
.
backupService
.
getWorkspaceBackupPaths
Sync
();
const
workspacesWithBackups
=
this
.
backupService
.
getWorkspaceBackupPaths
();
workspacesWithBackups
.
forEach
(
workspacePath
=>
{
if
(
!
fs
.
existsSync
(
workspacePath
))
{
...
...
src/vs/code/test/electron-main/backup.test.ts
浏览文件 @
50318f4d
...
...
@@ -26,6 +26,9 @@ class TestBackupService extends BackupService {
this
.
backupHome
=
backupHome
;
this
.
workspacesJsonPath
=
backupWorkspacesPath
;
// Force a reload with the new paths
this
.
loadSync
();
}
}
...
...
@@ -58,41 +61,41 @@ suite('BackupService', () => {
});
test
(
'
getWorkspaceBackupPathsSync should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
});
test
(
'
getWorkspaceBackupPathsSync should return [] when workspaces.json is not properly formed JSON
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
''
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{]
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
foo
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
});
test
(
'
getWorkspaceBackupPathsSync should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
});
test
(
'
getWorkspaceBackupPathsSync should return [] when folderWorkspaces in workspaces.json is not a string array
'
,
()
=>
{
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{}}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": ["bar"]}}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": []}}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":{"foo": "bar"}}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":"foo"}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
fs
.
writeFileSync
(
backupWorkspacesPath
,
'
{"folderWorkspaces":1}
'
);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[]);
});
test
(
'
pushWorkspaceBackupPathsSync should persist paths to workspaces.json
'
,
()
=>
{
backupService
.
pushWorkspaceBackupPathsSync
([
fooFile
,
barFile
]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
Sync
(),
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
assert
.
deepEqual
(
backupService
.
getWorkspaceBackupPaths
(),
[
fooFile
.
fsPath
,
barFile
.
fsPath
]);
});
test
(
'
getWorkspaceUntitledFileBackupsSync should return untitled file backup resources
'
,
done
=>
{
...
...
@@ -111,18 +114,16 @@ suite('BackupService', () => {
});
test
(
'
removeWorkspaceBackupPath should remove workspaces from workspaces.json
'
,
done
=>
{
const
workspacesJson
:
IBackupWorkspacesFormat
=
{
folderWorkspaces
:
[
fooFile
.
fsPath
,
barFile
.
fsPath
]
};
pfs
.
writeFileAndFlush
(
backupWorkspacesPath
,
JSON
.
stringify
(
workspacesJson
)).
then
(()
=>
{
backupService
.
removeWorkspaceBackupPathSync
(
fooFile
);
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
buffer
=>
{
const
json
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
buffer
);
assert
.
deepEqual
(
json
.
folderWorkspaces
,
[
barFile
.
fsPath
]);
backupService
.
removeWorkspaceBackupPathSync
(
barFile
);
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
content
=>
{
const
json2
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
content
);
assert
.
deepEqual
(
json2
.
folderWorkspaces
,
[]);
done
();
});
backupService
.
pushWorkspaceBackupPathsSync
([
fooFile
,
barFile
]);
backupService
.
removeWorkspaceBackupPathSync
(
fooFile
);
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
buffer
=>
{
const
json
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
buffer
);
assert
.
deepEqual
(
json
.
folderWorkspaces
,
[
barFile
.
fsPath
]);
backupService
.
removeWorkspaceBackupPathSync
(
barFile
);
pfs
.
readFile
(
backupWorkspacesPath
,
'
utf-8
'
).
then
(
content
=>
{
const
json2
=
<
IBackupWorkspacesFormat
>
JSON
.
parse
(
content
);
assert
.
deepEqual
(
json2
.
folderWorkspaces
,
[]);
done
();
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录