Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8eb696e4
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,发现更多精彩内容 >>
提交
8eb696e4
编写于
7月 03, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle disposables
上级
acaa0ea6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
38 deletion
+36
-38
src/vs/workbench/services/userData/common/fileUserDataProvider.ts
...orkbench/services/userData/common/fileUserDataProvider.ts
+1
-1
src/vs/workbench/services/userData/test/electron-browser/fileUserDataProvider.test.ts
...erData/test/electron-browser/fileUserDataProvider.test.ts
+35
-37
未找到文件。
src/vs/workbench/services/userData/common/fileUserDataProvider.ts
浏览文件 @
8eb696e4
...
...
@@ -24,7 +24,7 @@ export class FileUserDataProvider extends Disposable implements IUserDataProvide
)
{
super
();
// Assumption: This path always exists
this
.
fileService
.
watch
(
this
.
userDataHome
);
this
.
_register
(
this
.
fileService
.
watch
(
this
.
userDataHome
)
);
this
.
_register
(
this
.
fileService
.
onFileChanges
(
e
=>
this
.
handleFileChanges
(
e
)));
}
...
...
src/vs/workbench/services/userData/test/electron-browser/fileUserDataProvider.test.ts
浏览文件 @
8eb696e4
...
...
@@ -21,6 +21,7 @@ import { DiskFileSystemProvider } from 'vs/workbench/services/files/electron-bro
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IUserDataContainerRegistry
,
Extensions
}
from
'
vs/workbench/services/userData/common/userData
'
;
import
{
BACKUPS
}
from
'
vs/platform/environment/common/environment
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
suite
(
'
FileUserDataProvider
'
,
()
=>
{
...
...
@@ -30,24 +31,37 @@ suite('FileUserDataProvider', () => {
let
backupsPath
:
string
;
let
userDataResource
:
URI
;
const
userDataContainersRegistry
=
Registry
.
as
<
IUserDataContainerRegistry
>
(
Extensions
.
UserDataContainers
);
const
disposables
=
new
DisposableStore
();
setup
(
async
()
=>
{
const
logService
=
new
NullLogService
();
testObject
=
new
FileService
(
logService
);
testObject
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
logService
));
disposables
.
add
(
testObject
);
const
diskFileSystemProvider
=
new
DiskFileSystemProvider
(
logService
);
disposables
.
add
(
diskFileSystemProvider
);
disposables
.
add
(
testObject
.
registerProvider
(
Schemas
.
file
,
diskFileSystemProvider
));
rootPath
=
path
.
join
(
os
.
tmpdir
(),
'
vsctests
'
,
uuid
.
generateUuid
());
userDataPath
=
path
.
join
(
rootPath
,
'
user
'
);
backupsPath
=
path
.
join
(
rootPath
,
BACKUPS
);
await
Promise
.
all
([
pfs
.
mkdirp
(
userDataPath
),
pfs
.
mkdirp
(
backupsPath
)]);
userDataResource
=
URI
.
from
({
scheme
:
Schemas
.
userData
,
path
:
'
/user
'
});
testObject
.
registerProvider
(
Schemas
.
userData
,
new
UserDataFileSystemProvider
(
userDataResource
,
new
FileUserDataProvider
(
URI
.
file
(
userDataPath
),
testObject
)));
await
Promise
.
all
([
pfs
.
mkdirp
(
userDataPath
),
pfs
.
mkdirp
(
backupsPath
)]);
const
fileUserDataProvider
=
new
FileUserDataProvider
(
URI
.
file
(
userDataPath
),
testObject
);
disposables
.
add
(
fileUserDataProvider
);
const
userDataFileSystemProvider
=
new
UserDataFileSystemProvider
(
userDataResource
,
fileUserDataProvider
);
disposables
.
add
(
userDataFileSystemProvider
);
disposables
.
add
(
testObject
.
registerProvider
(
Schemas
.
userData
,
userDataFileSystemProvider
));
userDataContainersRegistry
.
registerContainer
(
'
testContainer
'
);
userDataContainersRegistry
.
registerContainer
(
'
testContainer/subContainer
'
);
userDataContainersRegistry
.
registerContainer
(
BACKUPS
);
});
teardown
(()
=>
{
return
pfs
.
rimraf
(
rootPath
,
pfs
.
RimRafMode
.
MOVE
);
teardown
(
async
()
=>
{
disposables
.
clear
();
await
pfs
.
rimraf
(
rootPath
,
pfs
.
RimRafMode
.
MOVE
);
});
test
(
'
exists return false when file does not exist
'
,
async
()
=>
{
...
...
@@ -89,10 +103,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is created
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -101,10 +114,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is created externally
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -114,10 +126,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is updated
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -127,10 +138,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is update externally
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -140,10 +150,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is deleted
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -153,10 +162,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file - event is triggerred when file is deleted externally
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -313,10 +321,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file under container - event is triggerred when file is created
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -325,10 +332,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file under container - event is triggerred when file is created externally
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -340,10 +346,9 @@ suite('FileUserDataProvider', () => {
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
pfs
.
mkdirp
(
path
.
join
(
userDataPath
,
'
testContainer
'
));
await
pfs
.
writeFile
(
path
.
join
(
userDataPath
,
'
testContainer
'
,
'
settings.json
'
),
'
{}
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -354,10 +359,9 @@ suite('FileUserDataProvider', () => {
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
pfs
.
mkdirp
(
path
.
join
(
userDataPath
,
'
testContainer
'
));
await
pfs
.
writeFile
(
path
.
join
(
userDataPath
,
'
testContainer
'
,
'
settings.json
'
),
'
{}
'
);
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -367,10 +371,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file under container - event is triggerred when file is deleted
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -380,10 +383,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch file under container - event is triggerred when file is deleted externally
'
,
async
(
done
)
=>
{
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
resource
);
disposables
.
add
(
testObject
.
watch
(
resource
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
resource
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -392,10 +394,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch container - event is triggerred when file under container is created
'
,
async
(
done
)
=>
{
const
container
=
joinPath
(
userDataResource
,
'
testContainer
'
);
const
disposable
=
testObject
.
watch
(
container
);
disposables
.
add
(
testObject
.
watch
(
container
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
container
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -405,10 +406,9 @@ suite('FileUserDataProvider', () => {
test
(
'
watch container - event is triggerred when file under container is created externally
'
,
async
(
done
)
=>
{
await
pfs
.
mkdirp
(
path
.
join
(
userDataPath
,
'
testContainer
'
));
const
container
=
joinPath
(
userDataResource
,
'
testContainer
'
);
const
disposable
=
testObject
.
watch
(
container
);
disposables
.
add
(
testObject
.
watch
(
container
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
container
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -419,10 +419,9 @@ suite('FileUserDataProvider', () => {
const
container
=
joinPath
(
userDataResource
,
'
testContainer
'
);
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
container
);
disposables
.
add
(
testObject
.
watch
(
container
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
container
))
{
disposable
.
dispose
();
done
();
}
});
...
...
@@ -433,10 +432,9 @@ suite('FileUserDataProvider', () => {
const
container
=
joinPath
(
userDataResource
,
'
testContainer
'
);
const
resource
=
joinPath
(
userDataResource
,
'
testContainer/settings.json
'
);
await
testObject
.
writeFile
(
resource
,
VSBuffer
.
fromString
(
'
{}
'
));
const
disposable
=
testObject
.
watch
(
container
);
disposables
.
add
(
testObject
.
watch
(
container
)
);
testObject
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
container
))
{
disposable
.
dispose
();
done
();
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录