Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d3a6a234
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,发现更多精彩内容 >>
提交
d3a6a234
编写于
10月 02, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove synchronization
上级
eeca0a4f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
1 addition
and
95 deletion
+1
-95
src/vs/platform/extensionManagement/node/multiExtensionManagement.ts
...form/extensionManagement/node/multiExtensionManagement.ts
+1
-95
未找到文件。
src/vs/platform/extensionManagement/node/multiExtensionManagement.ts
浏览文件 @
d3a6a234
...
...
@@ -5,19 +5,13 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Event
,
EventMultiplexer
}
from
'
vs/base/common/event
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
IExtensionManagementService
,
ILocalExtension
,
IGalleryExtension
,
LocalExtensionType
,
InstallExtensionEvent
,
DidInstallExtensionEvent
,
IExtensionIdentifier
,
DidUninstallExtensionEvent
,
IReportedExtension
,
IGalleryMetadata
,
IExtensionManagementServerService
,
IExtensionManagementServer
,
IExtensionGalleryService
,
InstallOperation
IExtensionManagementServerService
,
IExtensionManagementServer
,
IExtensionGalleryService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
isWorkspaceExtension
,
areSameExtensions
}
from
'
vs/platform/extensionManagement/common/extensionManagementUtil
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
INotificationService
,
Severity
,
INotificationHandle
}
from
'
vs/platform/notification/common/notification
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
...
...
@@ -37,9 +31,6 @@ export class MulitExtensionManagementService extends Disposable implements IExte
constructor
(
@
IExtensionManagementServerService
private
extensionManagementServerService
:
IExtensionManagementServerService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
IWindowService
private
windowService
:
IWindowService
,
@
ILogService
private
logService
:
ILogService
,
@
IExtensionGalleryService
private
extensionGalleryService
:
IExtensionGalleryService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
...
...
@@ -52,10 +43,6 @@ export class MulitExtensionManagementService extends Disposable implements IExte
this
.
onDidInstallExtension
=
this
.
_register
(
this
.
servers
.
reduce
((
emitter
:
EventMultiplexer
<
DidInstallExtensionEvent
>
,
server
)
=>
{
emitter
.
add
(
server
.
extensionManagementService
.
onDidInstallExtension
);
return
emitter
;
},
new
EventMultiplexer
<
DidInstallExtensionEvent
>
())).
event
;
this
.
onUninstallExtension
=
this
.
_register
(
this
.
servers
.
reduce
((
emitter
:
EventMultiplexer
<
IExtensionIdentifier
>
,
server
)
=>
{
emitter
.
add
(
server
.
extensionManagementService
.
onUninstallExtension
);
return
emitter
;
},
new
EventMultiplexer
<
IExtensionIdentifier
>
())).
event
;
this
.
onDidUninstallExtension
=
this
.
_register
(
this
.
servers
.
reduce
((
emitter
:
EventMultiplexer
<
DidUninstallExtensionEvent
>
,
server
)
=>
{
emitter
.
add
(
server
.
extensionManagementService
.
onDidUninstallExtension
);
return
emitter
;
},
new
EventMultiplexer
<
DidUninstallExtensionEvent
>
())).
event
;
if
(
this
.
otherServers
.
length
)
{
this
.
syncExtensions
();
}
}
getInstalled
(
type
?:
LocalExtensionType
):
TPromise
<
ILocalExtension
[]
>
{
...
...
@@ -115,85 +102,4 @@ export class MulitExtensionManagementService extends Disposable implements IExte
private
getServer
(
extension
:
ILocalExtension
):
IExtensionManagementServer
{
return
this
.
extensionManagementServerService
.
getExtensionManagementServer
(
extension
.
location
);
}
private
async
syncExtensions
():
Promise
<
void
>
{
this
.
localServer
.
extensionManagementService
.
getInstalled
(
LocalExtensionType
.
User
)
.
then
(
async
localExtensions
=>
{
const
workspaceExtensions
=
localExtensions
.
filter
(
e
=>
isWorkspaceExtension
(
e
.
manifest
,
this
.
configurationService
));
const
extensionsToSync
:
Map
<
IExtensionManagementServer
,
ILocalExtension
[]
>
=
await
this
.
getExtensionsToSync
(
workspaceExtensions
);
if
(
extensionsToSync
.
size
>
0
)
{
const
handler
=
this
.
notificationService
.
notify
({
severity
:
Severity
.
Info
,
message
:
localize
(
'
synchronising
'
,
"
Synchronising workspace extensions...
"
)
});
handler
.
progress
.
infinite
();
this
.
doSyncExtensions
(
extensionsToSync
,
handler
).
then
(()
=>
{
handler
.
progress
.
done
();
handler
.
updateMessage
(
localize
(
'
Synchronize.finished
'
,
"
Finished synchronising. Please reload now.
"
));
handler
.
updateActions
({
primary
:
[
new
Action
(
'
Synchronize.reloadNow
'
,
localize
(
'
Synchronize.reloadNow
'
,
"
Reload Now
"
),
null
,
true
,
()
=>
this
.
windowService
.
reloadWindow
())
]
});
},
error
=>
{
handler
.
progress
.
done
();
handler
.
updateSeverity
(
Severity
.
Error
);
handler
.
updateMessage
(
error
);
});
}
},
err
=>
this
.
logService
.
error
(
'
Error while Synchronisation
'
,
err
));
}
private
async
getExtensionsToSync
(
workspaceExtensions
:
ILocalExtension
[]):
Promise
<
Map
<
IExtensionManagementServer
,
ILocalExtension
[]
>>
{
const
extensionsToSync
:
Map
<
IExtensionManagementServer
,
ILocalExtension
[]
>
=
new
Map
<
IExtensionManagementServer
,
ILocalExtension
[]
>
();
for
(
const
server
of
this
.
otherServers
)
{
const
extensions
=
await
server
.
extensionManagementService
.
getInstalled
(
LocalExtensionType
.
User
);
const
groupedByVersionId
:
Map
<
string
,
ILocalExtension
>
=
extensions
.
reduce
((
groupedById
,
extension
)
=>
groupedById
.
set
(
`
${
extension
.
galleryIdentifier
.
id
}
-
${
extension
.
manifest
.
version
}
`
,
extension
),
new
Map
<
string
,
ILocalExtension
>
());
const
toSync
=
workspaceExtensions
.
filter
(
e
=>
!
groupedByVersionId
.
has
(
`
${
e
.
galleryIdentifier
.
id
}
-
${
e
.
manifest
.
version
}
`
));
if
(
toSync
.
length
)
{
extensionsToSync
.
set
(
server
,
toSync
);
}
}
return
extensionsToSync
;
}
private
async
doSyncExtensions
(
extensionsToSync
:
Map
<
IExtensionManagementServer
,
ILocalExtension
[]
>
,
notificationHandler
:
INotificationHandle
):
Promise
<
void
>
{
const
ids
:
string
[]
=
[];
const
zipLocationResolvers
:
TPromise
<
{
location
:
URI
,
vsix
:
boolean
}
>
[]
=
[];
extensionsToSync
.
forEach
(
extensions
=>
{
for
(
const
extension
of
extensions
)
{
if
(
ids
.
indexOf
(
extension
.
galleryIdentifier
.
id
)
===
-
1
)
{
ids
.
push
(
extension
.
galleryIdentifier
.
id
);
zipLocationResolvers
.
push
(
this
.
downloadFromGallery
(
extension
)
.
then
(
location
=>
location
?
{
location
,
vsix
:
true
}
:
this
.
localServer
.
extensionManagementService
.
zip
(
extension
).
then
(
location
=>
({
location
,
vsix
:
false
}))));
}
}
});
const
zipLocations
=
await
TPromise
.
join
(
zipLocationResolvers
);
const
promises
:
Promise
<
any
>
[]
=
[];
extensionsToSync
.
forEach
((
extensions
,
server
)
=>
{
let
promise
:
Promise
<
any
>
=
Promise
.
resolve
();
extensions
.
forEach
(
extension
=>
{
const
index
=
ids
.
indexOf
(
extension
.
galleryIdentifier
.
id
);
const
{
location
,
vsix
}
=
zipLocations
[
index
];
promise
=
promise
.
then
(()
=>
{
notificationHandler
.
updateMessage
(
localize
(
'
synchronising extension
'
,
"
Synchronising workspace extension: {0}
"
,
extension
.
manifest
.
displayName
||
extension
.
manifest
.
name
));
return
vsix
?
server
.
extensionManagementService
.
install
(
location
)
:
server
.
extensionManagementService
.
unzip
(
location
,
extension
.
type
);
}).
then
(
()
=>
pfs
.
rimraf
(
location
.
fsPath
),
error
=>
pfs
.
rimraf
(
location
.
fsPath
).
then
(()
=>
TPromise
.
wrapError
(
error
),
()
=>
TPromise
.
wrapError
(
error
)));
});
promises
.
push
(
promise
);
});
await
Promise
.
all
(
promises
);
}
private
downloadFromGallery
(
extension
:
ILocalExtension
):
TPromise
<
URI
>
{
if
(
this
.
extensionGalleryService
.
isEnabled
())
{
return
this
.
extensionGalleryService
.
getExtension
(
extension
.
galleryIdentifier
,
extension
.
manifest
.
version
)
.
then
(
galleryExtension
=>
galleryExtension
?
this
.
extensionGalleryService
.
download
(
galleryExtension
,
InstallOperation
.
None
).
then
(
location
=>
URI
.
file
(
location
))
:
null
);
}
return
TPromise
.
as
(
null
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录