Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
575a367a
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,体验更适合开发者的 AI 搜索 >>
提交
575a367a
编写于
11月 22, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage - move meta data into storage service too
上级
523fc339
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
41 deletion
+33
-41
src/vs/platform/storage/node/storageService.ts
src/vs/platform/storage/node/storageService.ts
+29
-2
src/vs/platform/workspaces/common/workspaces.ts
src/vs/platform/workspaces/common/workspaces.ts
+1
-0
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+2
-33
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+1
-6
未找到文件。
src/vs/platform/storage/node/storageService.ts
浏览文件 @
575a367a
...
...
@@ -15,7 +15,7 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
import
{
localize
}
from
'
vs/nls
'
;
import
{
mark
,
getDuration
}
from
'
vs/base/common/performance
'
;
import
{
join
}
from
'
path
'
;
import
{
copy
,
exists
,
mkdirp
,
readdir
}
from
'
vs/base/node/pfs
'
;
import
{
copy
,
exists
,
mkdirp
,
readdir
,
writeFile
}
from
'
vs/base/node/pfs
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWorkspaceInitializationPayload
,
isWorkspaceIdentifier
,
isSingleFolderWorkspaceInitializationPayload
}
from
'
vs/platform/workspaces/common/workspaces
'
;
...
...
@@ -31,6 +31,7 @@ export class StorageService extends Disposable implements IStorageService {
_serviceBrand
:
any
;
private
static
WORKSPACE_STORAGE_NAME
=
'
storage.db
'
;
private
static
WORKSPACE_META_NAME
=
'
workspace.json
'
;
private
_onDidChangeStorage
:
Emitter
<
IWorkspaceStorageChangeEvent
>
=
this
.
_register
(
new
Emitter
<
IWorkspaceStorageChangeEvent
>
());
get
onDidChangeStorage
():
Event
<
IWorkspaceStorageChangeEvent
>
{
return
this
.
_onDidChangeStorage
.
event
;
}
...
...
@@ -300,10 +301,36 @@ export class StorageService extends Disposable implements IStorageService {
return
{
path
:
workspaceStorageFolderPath
,
wasCreated
:
false
};
}
return
mkdirp
(
workspaceStorageFolderPath
).
then
(()
=>
({
path
:
workspaceStorageFolderPath
,
wasCreated
:
true
}));
return
mkdirp
(
workspaceStorageFolderPath
).
then
(()
=>
{
// Write metadata into folder
this
.
ensureWorkspaceStorageFolderMeta
(
payload
);
return
{
path
:
workspaceStorageFolderPath
,
wasCreated
:
true
};
});
});
}
private
ensureWorkspaceStorageFolderMeta
(
payload
:
IWorkspaceInitializationPayload
):
void
{
let
meta
:
object
;
if
(
isSingleFolderWorkspaceInitializationPayload
(
payload
))
{
meta
=
{
folder
:
payload
.
folder
.
toString
()
};
}
else
if
(
isWorkspaceIdentifier
(
payload
))
{
meta
=
{
configuration
:
payload
.
configPath
};
}
if
(
meta
)
{
const
workspaceStorageMetaPath
=
join
(
this
.
getWorkspaceStorageFolderPath
(
payload
),
StorageService
.
WORKSPACE_META_NAME
);
exists
(
workspaceStorageMetaPath
).
then
(
exists
=>
{
if
(
exists
)
{
return
void
0
;
// already existing
}
return
writeFile
(
workspaceStorageMetaPath
,
JSON
.
stringify
(
meta
,
void
0
,
2
));
}).
then
(
null
,
error
=>
onUnexpectedError
(
error
));
}
}
get
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
:
string
):
string
;
get
(
key
:
string
,
scope
:
StorageScope
):
string
|
undefined
;
get
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
?:
string
):
string
|
undefined
{
...
...
src/vs/platform/workspaces/common/workspaces.ts
浏览文件 @
575a367a
...
...
@@ -132,6 +132,7 @@ export function toWorkspaceIdentifier(workspace: IWorkspace): IWorkspaceIdentifi
export
type
IMultiFolderWorkspaceInitializationPayload
=
IWorkspaceIdentifier
;
export
interface
ISingleFolderWorkspaceInitializationPayload
{
id
:
string
;
folder
:
ISingleFolderWorkspaceIdentifier
;
}
export
interface
IEmptyWorkspaceInitializationPayload
{
id
:
string
;
}
export
type
IWorkspaceInitializationPayload
=
IMultiFolderWorkspaceInitializationPayload
|
ISingleFolderWorkspaceInitializationPayload
|
IEmptyWorkspaceInitializationPayload
;
export
function
isSingleFolderWorkspaceInitializationPayload
(
obj
:
any
):
obj
is
ISingleFolderWorkspaceInitializationPayload
{
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
575a367a
...
...
@@ -16,7 +16,7 @@ import { IWorkspaceContextService, Workspace, WorkbenchState } from 'vs/platform
import
{
WorkspaceService
}
from
'
vs/workbench/services/configuration/node/configurationService
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
stat
,
exists
,
writeFile
}
from
'
vs/base/node/pfs
'
;
import
{
stat
}
from
'
vs/base/node/pfs
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
*
as
gracefulFs
from
'
graceful-fs
'
;
import
{
KeyboardMapperFactory
}
from
'
vs/workbench/services/keybinding/electron-browser/keybindingService
'
;
...
...
@@ -44,7 +44,7 @@ import { MenubarChannelClient } from 'vs/platform/menubar/node/menubarIpc';
import
{
IMenubarService
}
from
'
vs/platform/menubar/common/menubar
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
sanitizeFilePath
}
from
'
vs/base/node/extfs
'
;
import
{
basename
,
join
}
from
'
path
'
;
import
{
basename
}
from
'
path
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
IdleValue
}
from
'
vs/base/common/async
'
;
import
{
setGlobalLeakWarningThreshold
}
from
'
vs/base/common/event
'
;
...
...
@@ -136,11 +136,6 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
storageService
},
mainServices
,
mainProcessClient
,
configuration
);
// Store meta file in workspace storage after workbench is running
shell
.
onRunning
(()
=>
{
ensureWorkspaceStorageFolderMeta
(
payload
,
workspaceService
,
environmentService
);
});
// Gracefully Shutdown Storage
shell
.
onShutdown
(
event
=>
{
event
.
join
(
storageService
.
close
());
...
...
@@ -255,32 +250,6 @@ function createStorageService(payload: IWorkspaceInitializationPayload, environm
});
}
function
getWorkspaceStoragePath
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IEnvironmentService
):
string
{
return
join
(
environmentService
.
workspaceStorageHome
,
payload
.
id
);
// workspace home + workspace id;
}
function
ensureWorkspaceStorageFolderMeta
(
payload
:
IWorkspaceInitializationPayload
,
workspaceService
:
IWorkspaceContextService
,
environmentService
:
IEnvironmentService
):
void
{
const
state
=
workspaceService
.
getWorkbenchState
();
if
(
state
===
WorkbenchState
.
EMPTY
)
{
return
;
// no storage meta for empty workspaces
}
const
workspaceStorageMetaPath
=
join
(
getWorkspaceStoragePath
(
payload
,
environmentService
),
'
workspace.json
'
);
exists
(
workspaceStorageMetaPath
).
then
(
exists
=>
{
if
(
exists
)
{
return
void
0
;
// already existing
}
const
workspace
=
workspaceService
.
getWorkspace
();
return
writeFile
(
workspaceStorageMetaPath
,
JSON
.
stringify
({
configuration
:
workspace
.
configuration
?
uri
.
revive
(
workspace
.
configuration
).
toString
()
:
void
0
,
folder
:
state
===
WorkbenchState
.
FOLDER
?
uri
.
revive
(
workspace
.
folders
[
0
].
uri
).
toString
()
:
void
0
},
undefined
,
2
));
}).
then
(
null
,
error
=>
onUnexpectedError
(
error
));
}
function
createStorageLegacyService
(
workspaceService
:
IWorkspaceContextService
,
environmentService
:
IEnvironmentService
):
IStorageLegacyService
{
let
workspaceId
:
string
;
...
...
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
575a367a
...
...
@@ -126,9 +126,6 @@ export class WorkbenchShell extends Disposable {
private
readonly
_onShutdown
=
this
.
_register
(
new
Emitter
<
ShutdownEvent
>
());
get
onShutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_onShutdown
.
event
;
}
private
readonly
_onRunning
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onRunning
():
Event
<
void
>
{
return
this
.
_onRunning
.
event
;
}
private
storageService
:
DelegatingStorageService
;
private
environmentService
:
IEnvironmentService
;
private
logService
:
ILogService
;
...
...
@@ -217,10 +214,8 @@ export class WorkbenchShell extends Disposable {
// Startup Workbench
workbench
.
startup
().
then
(
startupInfos
=>
{
// Set lifecycle phase to `Runnning` so that other contributions can
// now do something we also emit this as event to interested parties outside
// Set lifecycle phase to `Runnning`
this
.
lifecycleService
.
phase
=
LifecyclePhase
.
Running
;
this
.
_onRunning
.
fire
();
// Startup Telemetry
this
.
logStartupTelemetry
(
startupInfos
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录