Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
53a97fce
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,发现更多精彩内容 >>
提交
53a97fce
编写于
3月 20, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync global storage using registered sync storage keys
上级
84142c61
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
3 deletion
+37
-3
src/vs/platform/userDataSync/common/globalStateSync.ts
src/vs/platform/userDataSync/common/globalStateSync.ts
+31
-2
src/vs/platform/userDataSync/common/userDataSync.ts
src/vs/platform/userDataSync/common/userDataSync.ts
+6
-1
未找到文件。
src/vs/platform/userDataSync/common/globalStateSync.ts
浏览文件 @
53a97fce
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
SyncStatus
,
IUserDataSyncStoreService
,
IUserDataSyncLogService
,
IGlobalState
,
SyncResource
,
IUserDataSynchroniser
,
IUserDataSyncEnablementService
,
IUserDataSyncBackupStoreService
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
SyncStatus
,
IUserDataSyncStoreService
,
IUserDataSyncLogService
,
IGlobalState
,
SyncResource
,
IUserDataSynchroniser
,
IUserDataSyncEnablementService
,
IUserDataSyncBackupStoreService
,
IStorageValue
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -17,6 +17,8 @@ import { AbstractSynchroniser, IRemoteUserData } from 'vs/platform/userDataSync/
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageKeysSyncRegistryService
}
from
'
vs/platform/userDataSync/common/storageKeys
'
;
const
argvProperties
:
string
[]
=
[
'
locale
'
];
...
...
@@ -41,10 +43,13 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
@
IUserDataSyncEnablementService
userDataSyncEnablementService
:
IUserDataSyncEnablementService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IStorageService
private
readonly
storageService
:
IStorageService
,
@
IStorageKeysSyncRegistryService
private
readonly
storageKeysSyncRegistryService
:
IStorageKeysSyncRegistryService
,
)
{
super
(
SyncResource
.
GlobalState
,
fileService
,
environmentService
,
userDataSyncStoreService
,
userDataSyncBackupStoreService
,
userDataSyncEnablementService
,
telemetryService
,
logService
,
configurationService
);
this
.
_register
(
this
.
fileService
.
watch
(
dirname
(
this
.
environmentService
.
argvResource
)));
this
.
_register
(
Event
.
filter
(
this
.
fileService
.
onDidFilesChange
,
e
=>
e
.
contains
(
this
.
environmentService
.
argvResource
))(()
=>
this
.
_onDidChangeLocal
.
fire
()));
this
.
_register
(
Event
.
filter
(
this
.
storageService
.
onDidChangeStorage
,
e
=>
storageKeysSyncRegistryService
.
storageKeys
.
some
(({
key
})
=>
e
.
key
===
key
))(()
=>
this
.
_onDidChangeLocal
.
fire
()));
}
async
pull
():
Promise
<
void
>
{
...
...
@@ -205,7 +210,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
private
async
getLocalGlobalState
():
Promise
<
IGlobalState
>
{
const
argv
:
IStringDictionary
<
any
>
=
{};
const
storage
:
IStringDictionary
<
any
>
=
{};
const
storage
:
IStringDictionary
<
IStorageValue
>
=
{};
const
argvContent
:
string
=
await
this
.
getLocalArgvContent
();
const
argvValue
:
IStringDictionary
<
any
>
=
parse
(
argvContent
);
for
(
const
argvProperty
of
argvProperties
)
{
...
...
@@ -213,6 +218,12 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
argv
[
argvProperty
]
=
argvValue
[
argvProperty
];
}
}
for
(
const
{
key
,
version
}
of
this
.
storageKeysSyncRegistryService
.
storageKeys
)
{
const
value
=
this
.
storageService
.
get
(
key
,
StorageScope
.
GLOBAL
);
if
(
value
)
{
storage
[
key
]
=
{
version
,
value
};
}
}
return
{
argv
,
storage
};
}
...
...
@@ -231,7 +242,25 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
content
=
edit
(
content
,
[
argvProperty
],
globalState
.
argv
[
argvProperty
],
{});
}
if
(
argvContent
!==
content
)
{
this
.
logService
.
trace
(
`
${
this
.
syncResourceLogLabel
}
: Updating locale...`
);
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
argvResource
,
VSBuffer
.
fromString
(
content
));
this
.
logService
.
info
(
`
${
this
.
syncResourceLogLabel
}
: Updated locale.`
);
}
const
updatedStorage
:
IStringDictionary
<
any
>
=
{};
for
(
const
key
of
Object
.
keys
(
globalState
.
storage
))
{
const
{
version
,
value
}
=
globalState
.
storage
[
key
];
const
storageKey
=
this
.
storageKeysSyncRegistryService
.
storageKeys
.
filter
(
storageKey
=>
storageKey
.
key
===
key
)[
0
];
if
(
storageKey
&&
storageKey
.
version
===
version
&&
String
(
value
)
!==
String
(
this
.
storageService
.
get
(
key
,
StorageScope
.
GLOBAL
)))
{
updatedStorage
[
key
]
=
value
;
}
}
const
updatedStorageKeys
:
string
[]
=
Object
.
keys
(
updatedStorage
);
if
(
updatedStorageKeys
.
length
)
{
this
.
logService
.
trace
(
`
${
this
.
syncResourceLogLabel
}
: Updating global state...`
);
for
(
const
key
of
Object
.
keys
(
updatedStorage
))
{
this
.
storageService
.
store
(
key
,
updatedStorage
[
key
],
StorageScope
.
GLOBAL
);
}
this
.
logService
.
info
(
`
${
this
.
syncResourceLogLabel
}
: Updated global state`
,
Object
.
keys
(
updatedStorage
));
}
}
...
...
src/vs/platform/userDataSync/common/userDataSync.ts
浏览文件 @
53a97fce
...
...
@@ -231,9 +231,14 @@ export interface ISyncExtension {
disabled
?:
boolean
;
}
export
interface
IStorageValue
{
version
:
number
;
value
:
any
;
}
export
interface
IGlobalState
{
argv
:
IStringDictionary
<
any
>
;
storage
:
IStringDictionary
<
any
>
;
storage
:
IStringDictionary
<
IStorageValue
>
;
}
export
const
enum
SyncStatus
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录