Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3c0abb8d
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,发现更多精彩内容 >>
提交
3c0abb8d
编写于
7月 03, 2018
作者:
D
Dirk Baeumer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support to regenerate nsl cache if corrupted.
上级
e79e446e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
134 addition
and
55 deletion
+134
-55
src/bootstrap-amd.js
src/bootstrap-amd.js
+11
-2
src/main.js
src/main.js
+79
-45
src/vs/code/electron-browser/issue/issueReporter.js
src/vs/code/electron-browser/issue/issueReporter.js
+11
-2
src/vs/code/electron-browser/processExplorer/processExplorer.js
.../code/electron-browser/processExplorer/processExplorer.js
+11
-2
src/vs/code/electron-browser/sharedProcess/sharedProcess.js
src/vs/code/electron-browser/sharedProcess/sharedProcess.js
+11
-2
src/vs/workbench/electron-browser/bootstrap/index.js
src/vs/workbench/electron-browser/bootstrap/index.js
+11
-2
未找到文件。
src/bootstrap-amd.js
浏览文件 @
3c0abb8d
...
@@ -29,6 +29,8 @@ function readFile(file) {
...
@@ -29,6 +29,8 @@ function readFile(file) {
});
});
}
}
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
var
rawNlsConfig
=
process
.
env
[
'
VSCODE_NLS_CONFIG
'
];
var
rawNlsConfig
=
process
.
env
[
'
VSCODE_NLS_CONFIG
'
];
var
nlsConfig
=
rawNlsConfig
?
JSON
.
parse
(
rawNlsConfig
)
:
{
availableLanguages
:
{}
};
var
nlsConfig
=
rawNlsConfig
?
JSON
.
parse
(
rawNlsConfig
)
:
{
availableLanguages
:
{}
};
...
@@ -46,8 +48,15 @@ if (nlsConfig._resolvedLanguagePackCoreLocation) {
...
@@ -46,8 +48,15 @@ if (nlsConfig._resolvedLanguagePackCoreLocation) {
let
json
=
JSON
.
parse
(
content
);
let
json
=
JSON
.
parse
(
content
);
bundles
[
bundle
]
=
json
;
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
cb
(
undefined
,
json
);
})
}).
catch
((
error
)
=>
{
.
catch
(
cb
);
try
{
if
(
nlsConfig
.
_corruptedFile
)
{
writeFile
(
nlsConfig
.
_corruptedFile
,
'
corrupted
'
).
catch
(
function
(
error
)
{
console
.
error
(
error
);
});
}
}
finally
{
cb
(
error
,
undefined
);
}
});
};
};
}
}
...
...
src/main.js
浏览文件 @
3c0abb8d
...
@@ -123,6 +123,10 @@ const exists = file => new Promise(c => fs.exists(file, c));
...
@@ -123,6 +123,10 @@ const exists = file => new Promise(c => fs.exists(file, c));
const
readFile
=
file
=>
new
Promise
((
c
,
e
)
=>
fs
.
readFile
(
file
,
'
utf8
'
,
(
err
,
data
)
=>
err
?
e
(
err
)
:
c
(
data
)));
const
readFile
=
file
=>
new
Promise
((
c
,
e
)
=>
fs
.
readFile
(
file
,
'
utf8
'
,
(
err
,
data
)
=>
err
?
e
(
err
)
:
c
(
data
)));
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
const
touch
=
file
=>
new
Promise
((
c
,
e
)
=>
{
const
d
=
new
Date
();
fs
.
utimes
(
file
,
d
,
d
,
err
=>
err
?
e
(
err
)
:
c
());
});
const
touch
=
file
=>
new
Promise
((
c
,
e
)
=>
{
const
d
=
new
Date
();
fs
.
utimes
(
file
,
d
,
d
,
err
=>
err
?
e
(
err
)
:
c
());
});
const
lstat
=
file
=>
new
Promise
((
c
,
e
)
=>
fs
.
lstat
(
file
,
(
err
,
stats
)
=>
err
?
e
(
err
)
:
c
(
stats
)));
const
readdir
=
dir
=>
new
Promise
((
c
,
e
)
=>
fs
.
readdir
(
dir
,
(
err
,
files
)
=>
err
?
e
(
err
)
:
c
(
files
)));
const
rmdir
=
dir
=>
new
Promise
((
c
,
e
)
=>
fs
.
rmdir
(
dir
,
err
=>
err
?
e
(
err
)
:
c
(
undefined
)));
const
unlink
=
file
=>
new
Promise
((
c
,
e
)
=>
fs
.
unlink
(
file
,
err
=>
err
?
e
(
err
)
:
c
(
undefined
)));
function
mkdirp
(
dir
)
{
function
mkdirp
(
dir
)
{
return
mkdir
(
dir
).
then
(
null
,
err
=>
{
return
mkdir
(
dir
).
then
(
null
,
err
=>
{
...
@@ -138,6 +142,23 @@ function mkdirp(dir) {
...
@@ -138,6 +142,23 @@ function mkdirp(dir) {
});
});
}
}
function
rimraf
(
location
)
{
return
lstat
(
location
).
then
(
stat
=>
{
if
(
stat
.
isDirectory
()
&&
!
stat
.
isSymbolicLink
())
{
return
readdir
(
location
)
.
then
(
children
=>
Promise
.
all
(
children
.
map
(
child
=>
rimraf
(
path
.
join
(
location
,
child
)))))
.
then
(()
=>
rmdir
(
location
));
}
else
{
return
unlink
(
location
);
}
},
(
err
)
=>
{
if
(
err
.
code
===
'
ENOENT
'
)
{
return
void
0
;
}
throw
err
;
});
}
function
resolveJSFlags
(...
jsFlags
)
{
function
resolveJSFlags
(...
jsFlags
)
{
if
(
args
[
'
js-flags
'
])
{
if
(
args
[
'
js-flags
'
])
{
...
@@ -267,62 +288,75 @@ function getNLSConfiguration(locale) {
...
@@ -267,62 +288,75 @@ function getNLSConfiguration(locale) {
let
cacheRoot
=
path
.
join
(
userData
,
'
clp
'
,
packId
);
let
cacheRoot
=
path
.
join
(
userData
,
'
clp
'
,
packId
);
let
coreLocation
=
path
.
join
(
cacheRoot
,
commit
);
let
coreLocation
=
path
.
join
(
cacheRoot
,
commit
);
let
translationsConfigFile
=
path
.
join
(
cacheRoot
,
'
tcf.json
'
);
let
translationsConfigFile
=
path
.
join
(
cacheRoot
,
'
tcf.json
'
);
let
corruptedFile
=
path
.
join
(
cacheRoot
,
'
corrupted.info
'
);
let
result
=
{
let
result
=
{
locale
:
initialLocale
,
locale
:
initialLocale
,
availableLanguages
:
{
'
*
'
:
locale
},
availableLanguages
:
{
'
*
'
:
locale
},
_languagePackId
:
packId
,
_languagePackId
:
packId
,
_translationsConfigFile
:
translationsConfigFile
,
_translationsConfigFile
:
translationsConfigFile
,
_cacheRoot
:
cacheRoot
,
_cacheRoot
:
cacheRoot
,
_resolvedLanguagePackCoreLocation
:
coreLocation
_resolvedLanguagePackCoreLocation
:
coreLocation
,
_corruptedFile
:
corruptedFile
};
};
return
exists
(
coreLocation
).
then
((
fileExists
)
=>
{
return
exists
(
corruptedFile
).
then
((
corrupted
)
=>
{
if
(
fileExists
)
{
// The nls cache directory is corrupted.
// We don't wait for this. No big harm if we can't touch
let
toDelete
;
touch
(
coreLocation
).
catch
(()
=>
{
});
if
(
corrupted
)
{
perf
.
mark
(
'
nlsGeneration:end
'
);
toDelete
=
rimraf
(
cacheRoot
);
return
result
;
}
else
{
toDelete
=
Promise
.
resolve
(
undefined
);
}
}
return
mkdirp
(
coreLocation
).
then
(()
=>
{
return
toDelete
.
then
(()
=>
{
return
Promise
.
all
([
readFile
(
path
.
join
(
__dirname
,
'
nls.metadata.json
'
)),
readFile
(
mainPack
)]);
return
exists
(
coreLocation
).
then
((
fileExists
)
=>
{
}).
then
((
values
)
=>
{
if
(
fileExists
)
{
let
metadata
=
JSON
.
parse
(
values
[
0
]);
// We don't wait for this. No big harm if we can't touch
let
packData
=
JSON
.
parse
(
values
[
1
]).
contents
;
touch
(
coreLocation
).
catch
(()
=>
{
});
let
bundles
=
Object
.
keys
(
metadata
.
bundles
);
perf
.
mark
(
'
nlsGeneration:end
'
);
let
writes
=
[];
return
result
;
for
(
let
bundle
of
bundles
)
{
}
let
modules
=
metadata
.
bundles
[
bundle
];
return
mkdirp
(
coreLocation
).
then
(()
=>
{
let
target
=
Object
.
create
(
null
);
return
Promise
.
all
([
readFile
(
path
.
join
(
__dirname
,
'
nls.metadata.json
'
)),
readFile
(
mainPack
)]);
for
(
let
module
of
modules
)
{
}).
then
((
values
)
=>
{
let
keys
=
metadata
.
keys
[
module
];
let
metadata
=
JSON
.
parse
(
values
[
0
]);
let
defaultMessages
=
metadata
.
messages
[
module
];
let
packData
=
JSON
.
parse
(
values
[
1
]).
contents
;
let
translations
=
packData
[
module
];
let
bundles
=
Object
.
keys
(
metadata
.
bundles
);
let
targetStrings
;
let
writes
=
[];
if
(
translations
)
{
for
(
let
bundle
of
bundles
)
{
targetStrings
=
[];
let
modules
=
metadata
.
bundles
[
bundle
];
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
let
target
=
Object
.
create
(
null
);
let
elem
=
keys
[
i
];
for
(
let
module
of
modules
)
{
let
key
=
typeof
elem
===
'
string
'
?
elem
:
elem
.
key
;
let
keys
=
metadata
.
keys
[
module
];
let
translatedMessage
=
translations
[
key
];
let
defaultMessages
=
metadata
.
messages
[
module
];
if
(
translatedMessage
===
undefined
)
{
let
translations
=
packData
[
module
];
translatedMessage
=
defaultMessages
[
i
];
let
targetStrings
;
if
(
translations
)
{
targetStrings
=
[];
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
let
elem
=
keys
[
i
];
let
key
=
typeof
elem
===
'
string
'
?
elem
:
elem
.
key
;
let
translatedMessage
=
translations
[
key
];
if
(
translatedMessage
===
undefined
)
{
translatedMessage
=
defaultMessages
[
i
];
}
targetStrings
.
push
(
translatedMessage
);
}
}
else
{
targetStrings
=
defaultMessages
;
}
}
target
Strings
.
push
(
translatedMessage
)
;
target
[
module
]
=
targetStrings
;
}
}
}
else
{
writes
.
push
(
writeFile
(
path
.
join
(
coreLocation
,
bundle
.
replace
(
/
\/
/g
,
'
!
'
)
+
'
.nls.json
'
),
JSON
.
stringify
(
target
)));
targetStrings
=
defaultMessages
;
}
}
target
[
module
]
=
targetStrings
;
writes
.
push
(
writeFile
(
translationsConfigFile
,
JSON
.
stringify
(
packConfig
.
translations
)));
}
return
Promise
.
all
(
writes
);
writes
.
push
(
writeFile
(
path
.
join
(
coreLocation
,
bundle
.
replace
(
/
\/
/g
,
'
!
'
)
+
'
.nls.json
'
),
JSON
.
stringify
(
target
)));
}).
then
(()
=>
{
}
perf
.
mark
(
'
nlsGeneration:end
'
);
writes
.
push
(
writeFile
(
translationsConfigFile
,
JSON
.
stringify
(
packConfig
.
translations
)));
return
result
;
return
Promise
.
all
(
writes
);
}).
catch
((
err
)
=>
{
}).
then
(()
=>
{
console
.
error
(
'
Generating translation files failed.
'
,
err
);
perf
.
mark
(
'
nlsGeneration:end
'
);
return
defaultResult
(
locale
);
return
result
;
});
}).
catch
((
err
)
=>
{
});
console
.
error
(
'
Generating translation files failed.
'
,
err
);
return
defaultResult
(
locale
);
});
});
});
});
});
});
...
...
src/vs/code/electron-browser/issue/issueReporter.js
浏览文件 @
3c0abb8d
...
@@ -45,6 +45,8 @@ function readFile(file) {
...
@@ -45,6 +45,8 @@ function readFile(file) {
});
});
}
}
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
function
main
()
{
function
main
()
{
const
args
=
parseURLQueryArgs
();
const
args
=
parseURLQueryArgs
();
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
...
@@ -127,8 +129,15 @@ function main() {
...
@@ -127,8 +129,15 @@ function main() {
let
json
=
JSON
.
parse
(
content
);
let
json
=
JSON
.
parse
(
content
);
bundles
[
bundle
]
=
json
;
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
cb
(
undefined
,
json
);
})
}).
catch
((
error
)
=>
{
.
catch
(
cb
);
try
{
if
(
nlsConfig
.
_corruptedFile
)
{
writeFile
(
nlsConfig
.
_corruptedFile
,
'
corrupted
'
).
catch
(
function
(
error
)
{
console
.
error
(
error
);
});
}
}
finally
{
cb
(
error
,
undefined
);
}
});
};
};
}
}
...
...
src/vs/code/electron-browser/processExplorer/processExplorer.js
浏览文件 @
3c0abb8d
...
@@ -45,6 +45,8 @@ function readFile(file) {
...
@@ -45,6 +45,8 @@ function readFile(file) {
});
});
}
}
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
function
main
()
{
function
main
()
{
const
args
=
parseURLQueryArgs
();
const
args
=
parseURLQueryArgs
();
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
...
@@ -102,8 +104,15 @@ function main() {
...
@@ -102,8 +104,15 @@ function main() {
let
json
=
JSON
.
parse
(
content
);
let
json
=
JSON
.
parse
(
content
);
bundles
[
bundle
]
=
json
;
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
cb
(
undefined
,
json
);
})
}).
catch
((
error
)
=>
{
.
catch
(
cb
);
try
{
if
(
nlsConfig
.
_corruptedFile
)
{
writeFile
(
nlsConfig
.
_corruptedFile
,
'
corrupted
'
).
catch
(
function
(
error
)
{
console
.
error
(
error
);
});
}
}
finally
{
cb
(
error
,
undefined
);
}
});
};
};
}
}
...
...
src/vs/code/electron-browser/sharedProcess/sharedProcess.js
浏览文件 @
3c0abb8d
...
@@ -53,6 +53,8 @@ function readFile(file) {
...
@@ -53,6 +53,8 @@ function readFile(file) {
});
});
}
}
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
function
main
()
{
function
main
()
{
const
args
=
parseURLQueryArgs
();
const
args
=
parseURLQueryArgs
();
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
const
configuration
=
JSON
.
parse
(
args
[
'
config
'
]
||
'
{}
'
)
||
{};
...
@@ -111,8 +113,15 @@ function main() {
...
@@ -111,8 +113,15 @@ function main() {
let
json
=
JSON
.
parse
(
content
);
let
json
=
JSON
.
parse
(
content
);
bundles
[
bundle
]
=
json
;
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
cb
(
undefined
,
json
);
})
}).
catch
((
error
)
=>
{
.
catch
(
cb
);
try
{
if
(
nlsConfig
.
_corruptedFile
)
{
writeFile
(
nlsConfig
.
_corruptedFile
,
'
corrupted
'
).
catch
(
function
(
error
)
{
console
.
error
(
error
);
});
}
}
finally
{
cb
(
error
,
undefined
);
}
});
};
};
}
}
...
...
src/vs/workbench/electron-browser/bootstrap/index.js
浏览文件 @
3c0abb8d
...
@@ -81,6 +81,8 @@ function readFile(file) {
...
@@ -81,6 +81,8 @@ function readFile(file) {
});
});
}
}
const
writeFile
=
(
file
,
content
)
=>
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
file
,
content
,
'
utf8
'
,
err
=>
err
?
e
(
err
)
:
c
()));
function
registerListeners
(
enableDeveloperTools
)
{
function
registerListeners
(
enableDeveloperTools
)
{
// Devtools & reload support
// Devtools & reload support
...
@@ -180,8 +182,15 @@ function main() {
...
@@ -180,8 +182,15 @@ function main() {
let
json
=
JSON
.
parse
(
content
);
let
json
=
JSON
.
parse
(
content
);
bundles
[
bundle
]
=
json
;
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
cb
(
undefined
,
json
);
})
}).
catch
((
error
)
=>
{
.
catch
(
cb
);
try
{
if
(
nlsConfig
.
_corruptedFile
)
{
writeFile
(
nlsConfig
.
_corruptedFile
,
'
corrupted
'
).
catch
(
function
(
error
)
{
console
.
error
(
error
);
});
}
}
finally
{
cb
(
error
,
undefined
);
}
});
};
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录