Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b644e499
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,发现更多精彩内容 >>
提交
b644e499
编写于
9月 23, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add IntegrityService
上级
b1a27e7e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
138 addition
and
1 deletion
+138
-1
src/vs/platform/integrity/common/integrity.ts
src/vs/platform/integrity/common/integrity.ts
+29
-0
src/vs/platform/integrity/node/integrityServiceImpl.ts
src/vs/platform/integrity/node/integrityServiceImpl.ts
+101
-0
src/vs/platform/product.ts
src/vs/platform/product.ts
+1
-0
src/vs/workbench/electron-browser/bootstrap/index.js
src/vs/workbench/electron-browser/bootstrap/index.js
+2
-1
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+5
-0
未找到文件。
src/vs/platform/integrity/common/integrity.ts
0 → 100644
浏览文件 @
b644e499
/*---------------------------------------------------------------------------------------------
* 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
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
URI
from
'
vs/base/common/uri
'
;
export
const
IIntegrityService
=
createDecorator
<
IIntegrityService
>
(
'
integrityService
'
);
export
interface
ChecksumPair
{
uri
:
URI
;
actual
:
string
;
expected
:
string
;
isPure
:
boolean
;
}
export
interface
IntegrityTestResult
{
isPure
:
boolean
;
proof
:
ChecksumPair
[];
}
export
interface
IIntegrityService
{
_serviceBrand
:
any
;
isPure
():
TPromise
<
IntegrityTestResult
>
;
}
src/vs/platform/integrity/node/integrityServiceImpl.ts
0 → 100644
浏览文件 @
b644e499
/*---------------------------------------------------------------------------------------------
* 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
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IIntegrityService
,
IntegrityTestResult
,
ChecksumPair
}
from
'
vs/platform/integrity/common/integrity
'
;
import
product
from
'
vs/platform/product
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
fs
from
'
fs
'
;
const
crypto
=
require
(
'
crypto
'
);
interface
ILoaderChecksums
{
[
scriptSrc
:
string
]:
string
;
}
export
class
IntegrityServiceImpl
implements
IIntegrityService
{
public
_serviceBrand
:
any
;
private
_loaderChecksums
:
ILoaderChecksums
;
constructor
()
{
// Fetch checksums from loader
let
loaderChecksums
=
<
ILoaderChecksums
>
(
<
any
>
require
).
getChecksums
();
// Transform loader checksums to be uri => checksum
this
.
_loaderChecksums
=
Object
.
create
(
null
);
Object
.
keys
(
loaderChecksums
).
forEach
((
scriptSrc
)
=>
{
let
scriptUri
=
URI
.
file
(
scriptSrc
).
toString
();
this
.
_loaderChecksums
[
scriptUri
.
toString
()]
=
loaderChecksums
[
scriptSrc
];
});
}
public
isPure
():
TPromise
<
IntegrityTestResult
>
{
const
expectedChecksums
=
product
.
checksums
||
{};
let
syncResults
:
ChecksumPair
[]
=
[];
let
asyncResults
:
TPromise
<
ChecksumPair
>
[]
=
[];
Object
.
keys
(
expectedChecksums
).
forEach
((
filename
)
=>
{
let
r
=
this
.
_resolve
(
filename
,
expectedChecksums
[
filename
]);
if
(
TPromise
.
is
(
r
))
{
asyncResults
.
push
(
r
);
}
else
{
syncResults
.
push
(
r
);
}
});
return
TPromise
.
join
(
asyncResults
).
then
<
IntegrityTestResult
>
((
asyncResults
)
=>
{
let
allResults
=
syncResults
.
concat
(
asyncResults
);
let
isPure
=
true
;
for
(
let
i
=
0
,
len
=
allResults
.
length
;
isPure
&&
i
<
len
;
i
++
)
{
if
(
!
allResults
[
i
].
isPure
)
{
isPure
=
false
;
}
}
return
{
isPure
:
isPure
,
proof
:
allResults
};
});
}
private
_resolve
(
filename
:
string
,
expected
:
string
):
ChecksumPair
|
TPromise
<
ChecksumPair
>
{
let
fileUri
=
URI
.
parse
(
require
.
toUrl
(
filename
));
let
loaderChecksum
=
this
.
_loaderChecksums
[
fileUri
.
toString
()];
if
(
loaderChecksum
)
{
return
IntegrityServiceImpl
.
_createChecksumPair
(
fileUri
,
loaderChecksum
,
expected
);
}
if
(
/
\.
js$/
.
test
(
filename
))
{
console
.
warn
(
`Did not find checksum for
${
filename
}
in loader checksums.`
);
}
return
new
TPromise
<
ChecksumPair
>
((
c
,
e
,
p
)
=>
{
fs
.
readFile
(
fileUri
.
fsPath
,
(
err
,
buff
)
=>
{
if
(
err
)
{
return
e
(
err
);
}
c
(
IntegrityServiceImpl
.
_createChecksumPair
(
fileUri
,
this
.
_computeChecksum
(
buff
),
expected
));
});
});
}
private
_computeChecksum
(
buff
:
Buffer
):
string
{
let
hash
=
crypto
.
createHash
(
'
md5
'
)
.
update
(
buff
)
.
digest
(
'
base64
'
)
.
replace
(
/=+$/
,
''
);
return
hash
;
}
private
static
_createChecksumPair
(
uri
:
URI
,
actual
:
string
,
expected
:
string
):
ChecksumPair
{
return
{
uri
:
uri
,
actual
:
actual
,
expected
:
expected
,
isPure
:
(
actual
===
expected
)
};
}
}
src/vs/platform/product.ts
浏览文件 @
b644e499
...
...
@@ -45,6 +45,7 @@ export interface IProductConfiguration {
licenseUrl
:
string
;
privacyStatementUrl
:
string
;
npsSurveyUrl
:
string
;
checksums
:
{[
path
:
string
]:
string
;};
}
const
rootPath
=
path
.
dirname
(
uri
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
...
...
src/vs/workbench/electron-browser/bootstrap/index.js
浏览文件 @
b644e499
...
...
@@ -141,7 +141,8 @@ function main() {
recordStats
:
!!
configuration
.
performance
,
ignoreDuplicateModules
:
[
'
vs/workbench/parts/search/common/searchQuery
'
]
],
checksum
:
true
});
if
(
nlsConfig
.
pseudo
)
{
...
...
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
b644e499
...
...
@@ -46,6 +46,8 @@ import {ICompatWorkerService} from 'vs/editor/common/services/compatWorkerServic
import
{
MainThreadCompatWorkerService
}
from
'
vs/editor/common/services/compatWorkerServiceMain
'
;
import
{
CodeEditorServiceImpl
}
from
'
vs/editor/browser/services/codeEditorServiceImpl
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IntegrityServiceImpl
}
from
'
vs/platform/integrity/node/integrityServiceImpl
'
;
import
{
IIntegrityService
}
from
'
vs/platform/integrity/common/integrity
'
;
import
{
EditorWorkerServiceImpl
}
from
'
vs/editor/common/services/editorWorkerServiceImpl
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
MainProcessExtensionService
}
from
'
vs/workbench/api/node/mainThreadExtensionService
'
;
...
...
@@ -327,6 +329,9 @@ export class WorkbenchShell {
const
codeEditorService
=
instantiationService
.
createInstance
(
CodeEditorServiceImpl
);
serviceCollection
.
set
(
ICodeEditorService
,
codeEditorService
);
const
integrityService
=
instantiationService
.
createInstance
(
IntegrityServiceImpl
);
serviceCollection
.
set
(
IIntegrityService
,
integrityService
);
const
extensionManagementChannel
=
getDelayedChannel
<
IExtensionManagementChannel
>
(
sharedProcess
.
then
(
c
=>
c
.
getChannel
(
'
extensions
'
)));
const
extensionManagementChannelClient
=
new
ExtensionManagementChannelClient
(
extensionManagementChannel
);
serviceCollection
.
set
(
IExtensionManagementService
,
extensionManagementChannelClient
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录