Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
22e5e9fc
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,发现更多精彩内容 >>
提交
22e5e9fc
编写于
12月 02, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add nodeCachedDataManager for telemetry and cleanup
上级
83b929e1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
95 addition
and
6 deletion
+95
-6
src/vs/workbench/electron-browser/nodeCachedDataManager.ts
src/vs/workbench/electron-browser/nodeCachedDataManager.ts
+89
-0
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+6
-6
未找到文件。
src/vs/workbench/electron-browser/nodeCachedDataManager.ts
0 → 100644
浏览文件 @
22e5e9fc
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
dirname
,
join
}
from
'
vs/base/common/paths
'
;
import
{
readdir
,
rimraf
}
from
'
vs/base/node/pfs
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
export
class
NodeCachedDataManager
{
private
_telemetryService
:
ITelemetryService
;
private
_environmentService
:
IEnvironmentService
;
private
_disposables
:
IDisposable
[]
=
[];
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
)
{
this
.
_telemetryService
=
telemetryService
;
this
.
_environmentService
=
environmentService
;
this
.
_handleCachedDataErrors
();
this
.
_manageCachedDataSoon
();
}
dispose
():
void
{
this
.
_disposables
=
dispose
(
this
.
_disposables
);
}
private
_handleCachedDataErrors
():
void
{
const
onNodeCachedDataError
=
(
err
)
=>
{
this
.
_telemetryService
.
publicLog
(
'
nodeCachedData
'
,
{
errorCode
:
err
.
errorCode
,
path
:
err
.
path
});
};
// handle future and past errors
(
<
any
>
self
).
require
.
config
({
onNodeCachedDataError
},
true
);
(
<
any
[]
>
(
<
any
>
window
).
MonacoEnvironment
.
nodeCachedDataErrors
).
forEach
(
onNodeCachedDataError
);
delete
(
<
any
>
window
).
MonacoEnvironment
.
nodeCachedDataErrors
;
// stop when being disposed
this
.
_disposables
.
push
({
dispose
()
{
(
<
any
>
self
).
require
.
config
({
onNodeCachedDataError
:
undefined
},
true
);
}
});
}
private
_manageCachedDataSoon
():
void
{
// Cached data is stored as user data in directories like `CachedData/1.8.0`.
// This function makes sure to delete cached data from previous versions,
// like`CachedData/1.7.2`.
const
{
nodeCachedDataDir
}
=
this
.
_environmentService
;
if
(
!
nodeCachedDataDir
)
{
return
;
}
let
handle
=
setTimeout
(()
=>
{
handle
=
undefined
;
const
nodeCachedDataBase
=
dirname
(
nodeCachedDataDir
);
readdir
(
nodeCachedDataBase
).
then
(
entries
=>
{
const
deletes
=
entries
.
map
(
entry
=>
{
const
path
=
join
(
nodeCachedDataBase
,
entry
);
if
(
path
!==
nodeCachedDataDir
)
{
return
rimraf
(
path
);
}
});
return
TPromise
.
join
(
deletes
);
}).
done
(
undefined
,
onUnexpectedError
);
},
3
*
1000
);
this
.
_disposables
.
push
({
dispose
()
{
clearTimeout
(
handle
);
}
});
}
}
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
22e5e9fc
...
...
@@ -74,6 +74,7 @@ import { MainThreadModeServiceImpl } from 'vs/editor/common/services/modeService
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
CrashReporter
}
from
'
vs/workbench/electron-browser/crashReporter
'
;
import
{
NodeCachedDataManager
}
from
'
vs/workbench/electron-browser/nodeCachedDataManager
'
;
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
ThemeService
}
from
'
vs/workbench/services/themes/electron-browser/themeService
'
;
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
...
...
@@ -169,7 +170,12 @@ export class WorkbenchShell {
this
.
workbench
=
instantiationService
.
createInstance
(
Workbench
,
parent
.
getHTMLElement
(),
workbenchContainer
.
getHTMLElement
(),
this
.
workspace
,
this
.
options
,
serviceCollection
);
this
.
workbench
.
startup
({
onWorkbenchStarted
:
(
customKeybindingsCount
,
restoreViewletDuration
,
restoreEditorsDuration
)
=>
{
// run workbench started logic
this
.
onWorkbenchStarted
(
customKeybindingsCount
,
restoreViewletDuration
,
restoreEditorsDuration
);
// start cached data manager
instantiationService
.
createInstance
(
NodeCachedDataManager
);
}
});
...
...
@@ -276,12 +282,6 @@ export class WorkbenchShell {
const
workspaceStats
:
WorkspaceStats
=
<
WorkspaceStats
>
this
.
workbench
.
getInstantiationService
().
createInstance
(
WorkspaceStats
);
workspaceStats
.
reportWorkspaceTags
(
this
.
options
);
// Telemetry: node cached data error
const
onNodeCachedDataError
=
(
err
)
=>
{
this
.
telemetryService
.
publicLog
(
'
nodeCachedData
'
,
{
errorCode
:
err
.
errorCode
,
path
:
err
.
path
});
};
(
<
any
>
self
).
require
.
config
({
onNodeCachedDataError
},
true
);
(
<
any
[]
>
(
<
any
>
window
).
MonacoEnvironment
.
nodeCachedDataErrors
).
forEach
(
onNodeCachedDataError
);
delete
(
<
any
>
window
).
MonacoEnvironment
.
nodeCachedDataErrors
;
if
((
platform
.
isLinux
||
platform
.
isMacintosh
)
&&
process
.
getuid
()
===
0
)
{
this
.
messageService
.
show
(
Severity
.
Warning
,
nls
.
localize
(
'
runningAsRoot
'
,
"
It is recommended not to run Code as 'root'.
"
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录