Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
27f036cd
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,发现更多精彩内容 >>
提交
27f036cd
编写于
10月 25, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
intrdouce ISyncExtensionWithVersion type and use it for local extensions
上级
51dcc9d0
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
258 addition
and
245 deletion
+258
-245
src/vs/platform/userDataSync/common/extensionsMerge.ts
src/vs/platform/userDataSync/common/extensionsMerge.ts
+27
-18
src/vs/platform/userDataSync/common/extensionsSync.ts
src/vs/platform/userDataSync/common/extensionsSync.ts
+4
-4
src/vs/platform/userDataSync/common/userDataSync.ts
src/vs/platform/userDataSync/common/userDataSync.ts
+4
-0
src/vs/platform/userDataSync/test/common/extensionsMerge.test.ts
...platform/userDataSync/test/common/extensionsMerge.test.ts
+223
-223
未找到文件。
src/vs/platform/userDataSync/common/extensionsMerge.ts
浏览文件 @
27f036cd
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ISyncExtension
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
ISyncExtension
,
ISyncExtensionWithVersion
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
deepClone
,
equals
}
from
'
vs/base/common/objects
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
...
...
@@ -11,14 +11,14 @@ import { IStringDictionary } from 'vs/base/common/collections';
export
interface
IMergeResult
{
added
:
ISyncExtension
[];
removed
:
IExtensionIdentifier
[];
updated
:
ISyncExtension
[];
updated
:
ISyncExtension
WithVersion
[];
remote
:
ISyncExtension
[]
|
null
;
}
export
function
merge
(
localExtensions
:
ISyncExtension
[],
remoteExtensions
:
ISyncExtension
[]
|
null
,
lastSyncExtensions
:
ISyncExtension
[]
|
null
,
skippedExtensions
:
ISyncExtension
[],
ignoredExtensions
:
string
[]):
IMergeResult
{
export
function
merge
(
localExtensions
:
ISyncExtension
WithVersion
[],
remoteExtensions
:
ISyncExtension
[]
|
null
,
lastSyncExtensions
:
ISyncExtension
[]
|
null
,
skippedExtensions
:
ISyncExtension
[],
ignoredExtensions
:
string
[]):
IMergeResult
{
const
added
:
ISyncExtension
[]
=
[];
const
removed
:
IExtensionIdentifier
[]
=
[];
const
updated
:
ISyncExtension
[]
=
[];
const
updated
:
ISyncExtension
WithVersion
[]
=
[];
if
(
!
remoteExtensions
)
{
const
remote
=
localExtensions
.
filter
(({
identifier
})
=>
ignoredExtensions
.
every
(
id
=>
id
.
toLowerCase
()
!==
identifier
.
id
.
toLowerCase
()));
...
...
@@ -46,17 +46,23 @@ export function merge(localExtensions: ISyncExtension[], remoteExtensions: ISync
const
uuid
=
extension
.
identifier
.
uuid
||
uuids
.
get
(
extension
.
identifier
.
id
.
toLowerCase
());
return
uuid
?
`uuid:
${
uuid
}
`
:
`id:
${
extension
.
identifier
.
id
.
toLowerCase
()}
`
;
};
const
addExtensionToMap
=
(
map
:
Map
<
string
,
ISyncExtension
>
,
extension
:
ISyncExtension
)
=>
{
const
addExtensionToMap
=
<
T
extends
ISyncExtension
>
(
map
:
Map
<
string
,
T
>
,
extension
:
T
)
=>
{
map
.
set
(
getKey
(
extension
),
extension
);
return
map
;
};
const
localExtensionsMap
=
localExtensions
.
reduce
(
addExtensionToMap
,
new
Map
<
string
,
ISyncExten
sion
>
());
const
localExtensionsMap
:
Map
<
string
,
ISyncExtensionWithVersion
>
=
localExtensions
.
reduce
(
addExtensionToMap
,
new
Map
<
string
,
ISyncExtensionWithVer
sion
>
());
const
remoteExtensionsMap
=
remoteExtensions
.
reduce
(
addExtensionToMap
,
new
Map
<
string
,
ISyncExtension
>
());
const
newRemoteExtensionsMap
=
remoteExtensions
.
reduce
((
map
:
Map
<
string
,
ISyncExtension
>
,
extension
:
ISyncExtension
)
=>
{
const
key
=
getKey
(
extension
);
extension
=
deepClone
(
extension
);
if
(
localExtensionsMap
.
get
(
key
)?.
installed
)
{
extension
.
installed
=
true
;
const
localExtension
=
localExtensionsMap
.
get
(
key
);
if
(
localExtension
)
{
if
(
localExtension
.
installed
)
{
extension
.
installed
=
true
;
}
if
(
!
extension
.
version
)
{
extension
.
version
=
localExtension
.
version
;
}
}
return
addExtensionToMap
(
map
,
extension
);
},
new
Map
<
string
,
ISyncExtension
>
());
...
...
@@ -74,14 +80,17 @@ export function merge(localExtensions: ISyncExtension[], remoteExtensions: ISync
const
baseToRemote
=
compare
(
lastSyncExtensionsMap
,
remoteExtensionsMap
,
ignoredExtensionsSet
);
const
mergeAndUpdate
=
(
key
:
string
):
void
=>
{
const
localExtension
=
localExtensionsMap
.
get
(
key
)
!
;
const
remoteExtension
=
remoteExtensionsMap
.
get
(
key
)
!
;
// merge extension state only when version matches and local extension has state
if
(
remoteExtension
.
version
===
localExtension
.
version
&&
localExtension
.
state
)
{
remoteExtension
.
state
=
mergeExtensionState
(
localExtension
.
state
,
remoteExtension
.
state
,
lastSyncExtensionsMap
?.
get
(
key
)?.
state
);
const
localExtension
=
localExtensionsMap
.
get
(
key
);
if
(
localExtension
)
{
const
remoteExtension
=
remoteExtensionsMap
.
get
(
key
)
!
;
const
mergedExtension
:
ISyncExtensionWithVersion
=
{
...
remoteExtension
,
version
:
localExtension
.
version
};
// merge extension state only when version matches and local extension has state
if
(
remoteExtension
.
version
===
localExtension
.
version
&&
localExtension
.
state
)
{
mergedExtension
.
state
=
mergeExtensionState
(
localExtension
.
state
,
remoteExtension
.
state
,
lastSyncExtensionsMap
?.
get
(
key
)?.
state
);
}
updated
.
push
(
massageOutgoingExtension
(
mergedExtension
,
key
));
newRemoteExtensionsMap
.
set
(
key
,
remoteExtension
);
}
updated
.
push
(
massageOutgoingExtension
(
remoteExtension
,
key
));
newRemoteExtensionsMap
.
set
(
key
,
remoteExtension
);
};
// Remotely removed extension.
...
...
@@ -235,12 +244,12 @@ function isSameExtensionState(a: IStringDictionary<any> = {}, b: IStringDictiona
}
// massage incoming extension - add optional properties
function
massageIncomingExtension
(
extension
:
ISyncExtension
):
ISyncExtension
{
function
massageIncomingExtension
<
T
extends
ISyncExtension
>
(
extension
:
T
):
T
{
return
{
...
extension
,
...{
disabled
:
!!
extension
.
disabled
,
installed
:
!!
extension
.
installed
}
};
}
// massage outgoing extension - remove optional properties
function
massageOutgoingExtension
(
extension
:
ISyncExtension
,
key
:
string
):
ISyncExtension
{
function
massageOutgoingExtension
<
T
extends
ISyncExtension
>
(
extension
:
T
,
key
:
string
):
T
{
const
massagedExtension
:
ISyncExtension
=
{
identifier
:
{
id
:
extension
.
identifier
.
id
,
...
...
@@ -256,5 +265,5 @@ function massageOutgoingExtension(extension: ISyncExtension, key: string): ISync
if
(
extension
.
version
)
{
massagedExtension
.
version
=
extension
.
version
;
}
return
massagedExtension
;
return
massagedExtension
as
T
;
}
src/vs/platform/userDataSync/common/extensionsSync.ts
浏览文件 @
27f036cd
...
...
@@ -5,7 +5,7 @@
import
{
IUserDataSyncStoreService
,
ISyncExtension
,
IUserDataSyncLogService
,
IUserDataSynchroniser
,
SyncResource
,
IUserDataSyncResourceEnablementService
,
IUserDataSyncBackupStoreService
,
ISyncResourceHandle
,
USER_DATA_SYNC_SCHEME
,
IRemoteUserData
,
ISyncData
,
Change
IUserDataSyncBackupStoreService
,
ISyncResourceHandle
,
USER_DATA_SYNC_SCHEME
,
IRemoteUserData
,
ISyncData
,
Change
,
ISyncExtensionWithVersion
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -36,7 +36,7 @@ interface IExtensionResourceMergeResult extends IAcceptResult {
}
interface
IExtensionResourcePreview
extends
IResourcePreview
{
readonly
localExtensions
:
ISyncExtension
[];
readonly
localExtensions
:
ISyncExtension
WithVersion
[];
readonly
skippedExtensions
:
ISyncExtension
[];
readonly
previewResult
:
IExtensionResourceMergeResult
;
}
...
...
@@ -441,11 +441,11 @@ export class ExtensionsSynchroniser extends AbstractSynchroniser implements IUse
return
JSON
.
parse
(
syncData
.
content
);
}
private
getLocalExtensions
(
installedExtensions
:
ILocalExtension
[]):
ISyncExtension
[]
{
private
getLocalExtensions
(
installedExtensions
:
ILocalExtension
[]):
ISyncExtension
WithVersion
[]
{
const
disabledExtensions
=
this
.
extensionEnablementService
.
getDisabledExtensions
();
return
installedExtensions
.
map
(({
identifier
,
isBuiltin
,
manifest
})
=>
{
const
syncExntesion
:
ISyncExtension
=
{
identifier
,
version
:
manifest
.
version
};
const
syncExntesion
:
ISyncExtension
WithVersion
=
{
identifier
,
version
:
manifest
.
version
};
if
(
disabledExtensions
.
some
(
disabledExtension
=>
areSameExtensions
(
disabledExtension
,
identifier
)))
{
syncExntesion
.
disabled
=
true
;
}
...
...
src/vs/platform/userDataSync/common/userDataSync.ts
浏览文件 @
27f036cd
...
...
@@ -292,6 +292,10 @@ export interface ISyncExtension {
state
?:
IStringDictionary
<
any
>
;
}
export
interface
ISyncExtensionWithVersion
extends
ISyncExtension
{
version
:
string
;
}
export
interface
IStorageValue
{
version
:
number
;
value
:
string
;
...
...
src/vs/platform/userDataSync/test/common/extensionsMerge.test.ts
浏览文件 @
27f036cd
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录