Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7081def4
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 搜索 >>
提交
7081def4
编写于
3月 28, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage - remove global storage migration
上级
9eec0c53
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
2 addition
and
226 deletion
+2
-226
src/main.js
src/main.js
+0
-16
src/vs/platform/storage/node/storageMainService.ts
src/vs/platform/storage/node/storageMainService.ts
+2
-210
未找到文件。
src/main.js
浏览文件 @
7081def4
...
...
@@ -11,7 +11,6 @@ const lp = require('./vs/base/node/languagePacks');
perf
.
mark
(
'
main:started
'
);
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
bootstrap
=
require
(
'
./bootstrap
'
);
const
paths
=
require
(
'
./paths
'
);
...
...
@@ -29,21 +28,6 @@ bootstrap.enableASARSupport();
// Set userData path before app 'ready' event and call to process.chdir
const
args
=
parseCLIArgs
();
const
userDataPath
=
getUserDataPath
(
args
);
// global storage migration needs to happen very early before app.on("ready")
// TODO@Ben remove after a while
try
{
const
globalStorageHome
=
path
.
join
(
userDataPath
,
'
User
'
,
'
globalStorage
'
,
'
state.vscdb
'
);
const
localStorageHome
=
path
.
join
(
userDataPath
,
'
Local Storage
'
);
const
localStorageDB
=
path
.
join
(
localStorageHome
,
'
file__0.localstorage
'
);
const
localStorageDBBackup
=
path
.
join
(
localStorageHome
,
'
file__0.vscmig
'
);
if
(
!
fs
.
existsSync
(
globalStorageHome
)
&&
fs
.
existsSync
(
localStorageDB
))
{
fs
.
renameSync
(
localStorageDB
,
localStorageDBBackup
);
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
app
.
setPath
(
'
userData
'
,
userDataPath
);
// Update cwd based on environment and platform
...
...
src/vs/platform/storage/node/storageMainService.ts
浏览文件 @
7081def4
...
...
@@ -10,9 +10,7 @@ import { ILogService, LogLevel } from 'vs/platform/log/common/log';
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IStorage
,
Storage
,
SQLiteStorageDatabase
,
ISQLiteStorageDatabaseLoggingOptions
,
InMemoryStorageDatabase
}
from
'
vs/base/node/storage
'
;
import
{
join
}
from
'
vs/base/common/path
'
;
import
{
exists
,
readdir
}
from
'
vs/base/node/pfs
'
;
import
{
Database
}
from
'
vscode-sqlite3
'
;
import
{
endsWith
,
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
exists
}
from
'
vs/base/node/pfs
'
;
export
const
IStorageMainService
=
createDecorator
<
IStorageMainService
>
(
'
storageMainService
'
);
...
...
@@ -140,213 +138,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic
this
.
_register
(
this
.
storage
.
onDidChangeStorage
(
key
=>
this
.
_onDidChangeStorage
.
fire
({
key
})));
return
this
.
storage
.
init
().
then
(()
=>
{
// Migrate storage if this is the first start and we are not using in-memory
let
migrationPromise
:
Promise
<
void
>
;
if
(
!
useInMemoryStorage
&&
!
exists
)
{
// TODO@Ben remove global storage migration and move Storage creation back to ctor
migrationPromise
=
this
.
migrateGlobalStorage
().
then
(()
=>
this
.
logService
.
info
(
'
[storage] migrated global storage
'
),
error
=>
this
.
logService
.
error
(
`[storage] migration error
${
error
}
`
));
}
else
{
migrationPromise
=
Promise
.
resolve
();
}
return
migrationPromise
;
});
});
}
private
migrateGlobalStorage
():
Promise
<
void
>
{
this
.
logService
.
info
(
'
[storage] migrating global storage from localStorage into SQLite
'
);
const
localStorageDBBackup
=
join
(
this
.
environmentService
.
userDataPath
,
'
Local Storage
'
,
'
file__0.vscmig
'
);
return
exists
(
localStorageDBBackup
).
then
(
exists
=>
{
if
(
!
exists
)
{
return
Promise
.
resolve
();
// return if there is no DB to migrate from
}
return
readdir
(
this
.
environmentService
.
extensionsPath
).
then
(
extensions
=>
{
const
supportedKeys
=
new
Map
<
string
,
string
>
();
[
'
editorFontInfo
'
,
'
peekViewLayout
'
,
'
expandSuggestionDocs
'
,
'
extensionsIdentifiers/disabled
'
,
'
integrityService
'
,
'
telemetry.lastSessionDate
'
,
'
telemetry.instanceId
'
,
'
telemetry.firstSessionDate
'
,
'
workbench.sidebar.width
'
,
'
workbench.panel.width
'
,
'
workbench.panel.height
'
,
'
workbench.panel.sizeBeforeMaximized
'
,
'
workbench.activity.placeholderViewlets
'
,
'
colorThemeData
'
,
'
iconThemeData
'
,
'
workbench.telemetryOptOutShown
'
,
'
workbench.hide.welcome
'
,
'
releaseNotes/lastVersion
'
,
'
debug.actionswidgetposition
'
,
'
debug.actionswidgety
'
,
'
editor.neverPromptForLargeFiles
'
,
'
menubar/electronFixRecommended
'
,
'
learnMoreDirtyWriteError
'
,
'
extensions.ignoredAutoUpdateExtension
'
,
'
askToInstallRemoteServerExtension
'
,
'
hasNotifiedOfSettingsAutosave
'
,
'
commandPalette.mru.cache
'
,
'
commandPalette.mru.counter
'
,
'
parts-splash-data
'
,
'
terminal.integrated.neverMeasureRenderTime
'
,
'
terminal.integrated.neverSuggestSelectWindowsShell
'
,
'
memento/workbench.parts.editor
'
,
'
memento/workbench.view.search
'
,
'
langugage.update.donotask
'
,
'
extensionsAssistant/languagePackSuggestionIgnore
'
,
'
workbench.panel.pinnedPanels
'
,
'
workbench.activity.pinnedViewlets
'
,
'
extensionsAssistant/ignored_recommendations
'
,
'
extensionsAssistant/recommendations
'
,
'
extensionsAssistant/importantRecommendationsIgnore
'
,
'
extensionsAssistant/fileExtensionsSuggestionIgnore
'
,
'
nps/skipVersion
'
,
'
nps/lastSessionDate
'
,
'
nps/sessionCount
'
,
'
nps/isCandidate
'
,
'
allExperiments
'
,
'
currentOrPreviouslyRunExperiments
'
,
'
update/win32-64bits
'
,
'
update/win32-fast-updates
'
,
'
update/lastKnownVersion
'
,
'
update/updateNotificationTime
'
].
forEach
(
key
=>
supportedKeys
.
set
(
key
.
toLowerCase
(),
key
));
// https://github.com/Microsoft/vscode/issues/68468
const
wellKnownPublishers
=
[
'
Microsoft
'
,
'
GitHub
'
];
const
wellKnownExtensions
=
[
'
ms-vscode.Go
'
,
'
WallabyJs.quokka-vscode
'
,
'
Telerik.nativescript
'
,
'
Shan.code-settings-sync
'
,
'
ritwickdey.LiveServer
'
,
'
PKief.material-icon-theme
'
,
'
PeterJausovec.vscode-docker
'
,
'
ms-vscode.PowerShell
'
,
'
LaurentTreguier.vscode-simple-icons
'
,
'
KnisterPeter.vscode-github
'
,
'
DotJoshJohnson.xml
'
,
'
Dart-Code.dart-code
'
,
'
alefragnani.Bookmarks
'
];
// Support extension storage as well (always the ID of the extension)
extensions
.
forEach
(
extension
=>
{
let
extensionId
:
string
;
if
(
extension
.
indexOf
(
'
-
'
)
>=
0
)
{
extensionId
=
extension
.
substring
(
0
,
extension
.
lastIndexOf
(
'
-
'
));
// convert "author.extension-0.2.5" => "author.extension"
}
else
{
extensionId
=
extension
;
}
if
(
extensionId
)
{
for
(
let
i
=
0
;
i
<
wellKnownPublishers
.
length
;
i
++
)
{
const
publisher
=
wellKnownPublishers
[
i
];
if
(
startsWith
(
extensionId
,
`
${
publisher
.
toLowerCase
()}
.`
))
{
extensionId
=
`
${
publisher
}${
extensionId
.
substr
(
publisher
.
length
)}
`
;
break
;
}
}
for
(
let
j
=
0
;
j
<
wellKnownExtensions
.
length
;
j
++
)
{
const
wellKnownExtension
=
wellKnownExtensions
[
j
];
if
(
extensionId
===
wellKnownExtension
.
toLowerCase
())
{
extensionId
=
wellKnownExtension
;
break
;
}
}
supportedKeys
.
set
(
extensionId
.
toLowerCase
(),
extensionId
);
}
});
return
import
(
'
vscode-sqlite3
'
).
then
(
sqlite3
=>
{
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
const
handleSuffixKey
=
(
row
:
any
,
key
:
string
,
suffix
:
string
)
=>
{
if
(
endsWith
(
key
,
suffix
.
toLowerCase
()))
{
const
value
:
string
=
row
.
value
.
toString
(
'
utf16le
'
);
const
normalizedKey
=
key
.
substring
(
0
,
key
.
length
-
suffix
.
length
)
+
suffix
;
this
.
store
(
normalizedKey
,
value
);
return
true
;
}
return
false
;
};
const
db
:
Database
=
new
(
sqlite3
.
Database
)(
localStorageDBBackup
,
error
=>
{
if
(
error
)
{
if
(
db
)
{
db
.
close
();
}
return
reject
(
error
);
}
db
.
all
(
'
SELECT key, value FROM ItemTable
'
,
(
error
,
rows
)
=>
{
if
(
error
)
{
db
.
close
();
return
reject
(
error
);
}
try
{
rows
.
forEach
(
row
=>
{
let
key
:
string
=
row
.
key
;
if
(
key
.
indexOf
(
'
storage://global/
'
)
!==
0
)
{
return
;
// not a global key
}
// convert storage://global/colorthemedata => colorthemedata
key
=
key
.
substr
(
'
storage://global/
'
.
length
);
const
supportedKey
=
supportedKeys
.
get
(
key
);
if
(
supportedKey
)
{
const
value
:
string
=
row
.
value
.
toString
(
'
utf16le
'
);
this
.
store
(
supportedKey
,
value
);
}
// dynamic values
else
if
(
endsWith
(
key
,
'
.hidden
'
)
||
startsWith
(
key
,
'
experiments.
'
)
)
{
const
value
:
string
=
row
.
value
.
toString
(
'
utf16le
'
);
this
.
store
(
key
,
value
);
}
// fix lowercased ".sessionCount"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.sessionCount
'
))
{
}
// fix lowercased ".lastSessionDate"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.lastSessionDate
'
))
{
}
// fix lowercased ".skipVersion"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.skipVersion
'
))
{
}
// fix lowercased ".isCandidate"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.isCandidate
'
))
{
}
// fix lowercased ".editedCount"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.editedCount
'
))
{
}
// fix lowercased ".editedDate"
else
if
(
handleSuffixKey
(
row
,
key
,
'
.editedDate
'
))
{
}
});
db
.
close
();
}
catch
(
error
)
{
db
.
close
();
return
reject
(
error
);
}
resolve
();
});
});
});
});
});
return
this
.
storage
.
init
();
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录