Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
8429b398
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8429b398
编写于
11月 14, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move backup unload logic to an event
Fixes #15260
上级
23d3de42
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
16 deletion
+33
-16
src/vs/code/electron-main/lifecycle.ts
src/vs/code/electron-main/lifecycle.ts
+11
-12
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+1
-1
src/vs/platform/backup/electron-main/backupMainService.ts
src/vs/platform/backup/electron-main/backupMainService.ts
+19
-1
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
...tform/backup/test/electron-main/backupMainService.test.ts
+2
-2
未找到文件。
src/vs/code/electron-main/lifecycle.ts
浏览文件 @
8429b398
...
...
@@ -5,19 +5,18 @@
'
use strict
'
;
import
Uri
from
'
vs/base/common/uri
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
ipcMain
as
ipc
,
app
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ReadyState
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IBackupMainService
}
from
'
vs/platform/backup/common/backup
'
;
import
{
ILogService
}
from
'
vs/code/electron-main/log
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
const
EventTypes
=
{
BEFORE_QUIT
:
'
before-quit
'
BEFORE_QUIT
:
'
before-quit
'
,
AFTER_UNLOAD
:
'
after-unload
'
};
export
const
ILifecycleService
=
createDecorator
<
ILifecycleService
>
(
'
lifecycleService
'
);
...
...
@@ -31,6 +30,7 @@ export interface ILifecycleService {
wasUpdated
:
boolean
;
onBeforeQuit
(
clb
:
()
=>
void
):
()
=>
void
;
onAfterUnload
(
clb
:
(
VSCodeWindow
)
=>
void
):
()
=>
void
;
ready
():
void
;
registerWindow
(
vscodeWindow
:
VSCodeWindow
):
void
;
unload
(
vscodeWindow
:
VSCodeWindow
):
TPromise
<
boolean
/* veto */
>
;
...
...
@@ -54,8 +54,7 @@ export class LifecycleService implements ILifecycleService {
constructor
(
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
ILogService
private
logService
:
ILogService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IBackupMainService
private
backupService
:
IBackupMainService
@
IStorageService
private
storageService
:
IStorageService
)
{
this
.
windowToCloseRequest
=
Object
.
create
(
null
);
this
.
quitRequested
=
false
;
...
...
@@ -88,6 +87,12 @@ export class LifecycleService implements ILifecycleService {
return
()
=>
this
.
eventEmitter
.
removeListener
(
EventTypes
.
BEFORE_QUIT
,
clb
);
}
onAfterUnload
(
clb
:
(
VSCodeWindow
)
=>
void
):
()
=>
void
{
this
.
eventEmitter
.
addListener
(
EventTypes
.
AFTER_UNLOAD
,
clb
);
return
()
=>
this
.
eventEmitter
.
removeListener
(
EventTypes
.
AFTER_UNLOAD
,
clb
);
}
public
ready
():
void
{
this
.
registerListeners
();
}
...
...
@@ -163,13 +168,7 @@ export class LifecycleService implements ILifecycleService {
const
oneTimeCancelEvent
=
'
vscode:cancel
'
+
oneTimeEventToken
;
ipc
.
once
(
oneTimeOkEvent
,
()
=>
{
// Clear out any workspace backups from workspaces.json that don't have any backups
if
(
vscodeWindow
.
openedWorkspacePath
)
{
const
workspaceResource
=
Uri
.
file
(
vscodeWindow
.
openedWorkspacePath
);
if
(
!
this
.
backupService
.
hasWorkspaceBackup
(
workspaceResource
))
{
this
.
backupService
.
removeWorkspaceBackupPathSync
(
workspaceResource
);
}
}
this
.
eventEmitter
.
emit
(
EventTypes
.
AFTER_UNLOAD
,
vscodeWindow
);
c
(
false
);
// no veto
});
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
8429b398
...
...
@@ -35,7 +35,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
ILogService
,
MainLogService
}
from
'
vs/code/electron-main/log
'
;
import
{
IStorageService
,
StorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
IBackupMainService
}
from
'
vs/platform/backup/common/backup
'
;
import
{
BackupMainService
}
from
'
vs/platform/backup/
node
/backupMainService
'
;
import
{
BackupMainService
}
from
'
vs/platform/backup/
electron-main
/backupMainService
'
;
import
{
IEnvironmentService
,
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
src/vs/platform/backup/
node
/backupMainService.ts
→
src/vs/platform/backup/
electron-main
/backupMainService.ts
浏览文件 @
8429b398
...
...
@@ -10,6 +10,8 @@ import Uri from 'vs/base/common/uri';
import
{
readdirSync
}
from
'
vs/base/node/extfs
'
;
import
{
IBackupWorkspacesFormat
,
IBackupMainService
}
from
'
vs/platform/backup/common/backup
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ILifecycleService
}
from
'
vs/code/electron-main/lifecycle
'
;
import
{
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
export
class
BackupMainService
implements
IBackupMainService
{
...
...
@@ -21,13 +23,29 @@ export class BackupMainService implements IBackupMainService {
private
workspacesJsonContent
:
IBackupWorkspacesFormat
;
constructor
(
@
IEnvironmentService
environmentService
:
IEnvironmentService
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
)
{
this
.
backupHome
=
environmentService
.
backupHome
;
this
.
workspacesJsonPath
=
environmentService
.
backupWorkspacesPath
;
if
(
lifecycleService
)
{
lifecycleService
.
onAfterUnload
(
this
.
onAfterUnloadWindow
.
bind
(
this
));
}
this
.
loadSync
();
}
private
onAfterUnloadWindow
(
vscodeWindow
:
VSCodeWindow
)
{
if
(
vscodeWindow
.
openedWorkspacePath
)
{
// Clear out workspace from workspaces.json if it doesn't have any backups
const
workspaceResource
=
Uri
.
file
(
vscodeWindow
.
openedWorkspacePath
);
if
(
!
this
.
hasWorkspaceBackup
(
workspaceResource
))
{
this
.
removeWorkspaceBackupPathSync
(
workspaceResource
);
}
}
}
public
getWorkspaceBackupPaths
():
string
[]
{
return
this
.
workspacesJsonContent
.
folderWorkspaces
;
}
...
...
src/vs/platform/backup/test/
node
/backupMainService.test.ts
→
src/vs/platform/backup/test/
electron-main
/backupMainService.test.ts
浏览文件 @
8429b398
...
...
@@ -15,12 +15,12 @@ import extfs = require('vs/base/node/extfs');
import
pfs
=
require
(
'
vs/base/node/pfs
'
);
import
Uri
from
'
vs/base/common/uri
'
;
import
{
TestEnvironmentService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
BackupMainService
}
from
'
vs/platform/backup/
node
/backupMainService
'
;
import
{
BackupMainService
}
from
'
vs/platform/backup/
electron-main
/backupMainService
'
;
import
{
IBackupWorkspacesFormat
}
from
'
vs/platform/backup/common/backup
'
;
class
TestBackupMainService
extends
BackupMainService
{
constructor
(
backupHome
:
string
,
backupWorkspacesPath
:
string
)
{
super
(
TestEnvironmentService
);
super
(
TestEnvironmentService
,
null
);
this
.
backupHome
=
backupHome
;
this
.
workspacesJsonPath
=
backupWorkspacesPath
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录