Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
957534cd
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,发现更多精彩内容 >>
提交
957534cd
编写于
5月 17, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#91556 Check if there are changes to push to remote
上级
4f16ae67
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
6 deletion
+61
-6
src/vs/platform/userDataSync/common/abstractSynchronizer.ts
src/vs/platform/userDataSync/common/abstractSynchronizer.ts
+16
-3
src/vs/platform/userDataSync/common/extensionsSync.ts
src/vs/platform/userDataSync/common/extensionsSync.ts
+1
-1
src/vs/platform/userDataSync/common/globalStateSync.ts
src/vs/platform/userDataSync/common/globalStateSync.ts
+1
-1
src/vs/platform/userDataSync/common/snippetsSync.ts
src/vs/platform/userDataSync/common/snippetsSync.ts
+1
-1
src/vs/platform/userDataSync/test/common/settingsSync.test.ts
...vs/platform/userDataSync/test/common/settingsSync.test.ts
+19
-0
src/vs/platform/userDataSync/test/common/synchronizer.test.ts
...vs/platform/userDataSync/test/common/synchronizer.test.ts
+23
-0
未找到文件。
src/vs/platform/userDataSync/common/abstractSynchronizer.ts
浏览文件 @
957534cd
...
...
@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
import
{
SyncResource
,
SyncStatus
,
IUserData
,
IUserDataSyncStoreService
,
UserDataSyncErrorCode
,
UserDataSyncError
,
IUserDataSyncLogService
,
IUserDataSyncUtilService
,
IUserDataSyncEnablementService
,
IUserDataSyncBackupStoreService
,
Conflict
,
ISyncResourceHandle
,
USER_DATA_SYNC_SCHEME
,
ISyncPreviewResult
,
IUserDataManifest
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
joinPath
,
dirname
,
isEqual
,
basename
}
from
'
vs/base/common/resources
'
;
import
{
CancelablePromise
}
from
'
vs/base/common/async
'
;
import
{
CancelablePromise
,
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ParseError
,
parse
}
from
'
vs/base/common/json
'
;
...
...
@@ -57,7 +57,8 @@ export abstract class AbstractSynchroniser extends Disposable {
private
_onDidChangeConflicts
:
Emitter
<
Conflict
[]
>
=
this
.
_register
(
new
Emitter
<
Conflict
[]
>
());
readonly
onDidChangeConflicts
:
Event
<
Conflict
[]
>
=
this
.
_onDidChangeConflicts
.
event
;
protected
readonly
_onDidChangeLocal
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
private
readonly
localChangeTriggerScheduler
=
new
RunOnceScheduler
(()
=>
this
.
doTriggerLocalChange
(),
50
);
private
readonly
_onDidChangeLocal
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeLocal
:
Event
<
void
>
=
this
.
_onDidChangeLocal
.
event
;
protected
readonly
lastSyncResource
:
URI
;
...
...
@@ -80,6 +81,18 @@ export abstract class AbstractSynchroniser extends Disposable {
this
.
lastSyncResource
=
joinPath
(
this
.
syncFolder
,
`lastSync
${
this
.
resource
}
.json`
);
}
protected
async
triggerLocalChange
():
Promise
<
void
>
{
this
.
localChangeTriggerScheduler
.
schedule
();
}
protected
async
doTriggerLocalChange
():
Promise
<
void
>
{
const
lastSyncUserData
=
await
this
.
getLastSyncUserData
();
const
hasRemoteChanged
=
lastSyncUserData
?
(
await
this
.
generatePreview
(
lastSyncUserData
,
lastSyncUserData
)).
hasRemoteChanged
:
true
;
if
(
hasRemoteChanged
)
{
this
.
_onDidChangeLocal
.
fire
();
}
}
protected
setStatus
(
status
:
SyncStatus
):
void
{
if
(
this
.
_status
!==
status
)
{
const
oldStatus
=
this
.
_status
;
...
...
@@ -453,7 +466,7 @@ export abstract class AbstractFileSynchroniser extends AbstractSynchroniser {
// Otherwise fire change event
else
{
this
.
_onDidChangeLocal
.
fir
e
();
this
.
triggerLocalChang
e
();
}
}
...
...
src/vs/platform/userDataSync/common/extensionsSync.ts
浏览文件 @
957534cd
...
...
@@ -63,7 +63,7 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
Event
.
filter
(
this
.
extensionManagementService
.
onDidInstallExtension
,
(
e
=>
!!
e
.
gallery
)),
Event
.
filter
(
this
.
extensionManagementService
.
onDidUninstallExtension
,
(
e
=>
!
e
.
error
)),
this
.
extensionEnablementService
.
onDidChangeEnablement
),
()
=>
undefined
,
500
)(()
=>
this
.
_onDidChangeLocal
.
fir
e
()));
()
=>
undefined
,
500
)(()
=>
this
.
triggerLocalChang
e
()));
}
async
pull
():
Promise
<
void
>
{
...
...
src/vs/platform/userDataSync/common/globalStateSync.ts
浏览文件 @
957534cd
...
...
@@ -66,7 +66,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
Event
.
filter
(
this
.
storageService
.
onDidChangeStorage
,
e
=>
storageKeysSyncRegistryService
.
storageKeys
.
some
(({
key
})
=>
e
.
key
===
key
)),
/* Storage key registered */
this
.
storageKeysSyncRegistryService
.
onDidChangeStorageKeys
)((()
=>
this
.
_onDidChangeLocal
.
fir
e
()))
)((()
=>
this
.
triggerLocalChang
e
()))
);
}
...
...
src/vs/platform/userDataSync/common/snippetsSync.ts
浏览文件 @
957534cd
...
...
@@ -70,7 +70,7 @@ export class SnippetsSynchroniser extends AbstractSynchroniser implements IUserD
}
// Otherwise fire change event
else
{
this
.
_onDidChangeLocal
.
fir
e
();
this
.
triggerLocalChang
e
();
}
}
...
...
src/vs/platform/userDataSync/test/common/settingsSync.test.ts
浏览文件 @
957534cd
...
...
@@ -15,6 +15,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
import
{
ISyncData
}
from
'
vs/platform/userDataSync/common/abstractSynchronizer
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
,
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
suite
(
'
SettingsSync
'
,
()
=>
{
...
...
@@ -267,6 +268,24 @@ suite('SettingsSync', () => {
}`
);
});
test
(
'
local change event is triggered when settings are changed
'
,
async
()
=>
{
const
content
=
`{
"files.autoSave": "afterDelay",
"files.simpleDialog.enable": true,
}`
;
await
updateSettings
(
content
);
await
testObject
.
sync
(
await
client
.
manifest
());
const
promise
=
Event
.
toPromise
(
testObject
.
onDidChangeLocal
);
await
updateSettings
(
`{
"files.autoSave": "off",
"files.simpleDialog.enable": true,
}`
);
await
promise
;
});
test
(
'
do not sync ignored settings
'
,
async
()
=>
{
const
settingsContent
=
`{
...
...
src/vs/platform/userDataSync/test/common/synchronizer.test.ts
浏览文件 @
957534cd
...
...
@@ -51,6 +51,16 @@ class TestSynchroniser extends AbstractSynchroniser {
this
.
syncBarrier
.
open
();
}
async
triggerLocalChange
():
Promise
<
void
>
{
super
.
triggerLocalChange
();
}
onDidTriggerLocalChangeCall
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
protected
async
doTriggerLocalChange
():
Promise
<
void
>
{
await
super
.
doTriggerLocalChange
();
this
.
onDidTriggerLocalChangeCall
.
fire
();
}
protected
async
generatePreview
(
remoteUserData
:
IRemoteUserData
,
lastSyncUserData
:
IRemoteUserData
|
null
):
Promise
<
ISyncPreviewResult
>
{
return
{
hasLocalChanged
:
false
,
hasRemoteChanged
:
false
};
}
...
...
@@ -203,5 +213,18 @@ suite('TestSynchronizer', () => {
]);
});
test
(
'
no requests are made to server when local change is triggered
'
,
async
()
=>
{
const
testObject
:
TestSynchroniser
=
client
.
instantiationService
.
createInstance
(
TestSynchroniser
,
SyncResource
.
Settings
);
testObject
.
syncBarrier
.
open
();
await
testObject
.
sync
(
await
client
.
manifest
());
server
.
reset
();
const
promise
=
Event
.
toPromise
(
testObject
.
onDidTriggerLocalChangeCall
.
event
);
await
testObject
.
triggerLocalChange
();
await
promise
;
assert
.
deepEqual
(
server
.
requests
,
[]);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录