Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5f973bc6
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,发现更多精彩内容 >>
提交
5f973bc6
编写于
10月 31, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #62152
上级
97ad72a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
45 deletion
+31
-45
src/vs/base/node/storage.ts
src/vs/base/node/storage.ts
+24
-38
src/vs/base/test/node/storage/storage.test.ts
src/vs/base/test/node/storage/storage.test.ts
+3
-3
src/vs/platform/storage/node/storageService.ts
src/vs/platform/storage/node/storageService.ts
+4
-4
未找到文件。
src/vs/base/node/storage.ts
浏览文件 @
5f973bc6
...
...
@@ -20,12 +20,11 @@ export interface IStorageOptions {
}
export
interface
IStorageLoggingOptions
{
errorLogger
?:
(
error
:
string
|
Error
)
=>
void
;
infoLogger
?:
(
msg
:
string
)
=>
void
;
logError
?:
(
error
:
string
|
Error
)
=>
void
;
info
?:
boolean
;
trace
?:
boolean
;
profile
?:
boolean
;
logTrace
?:
(
msg
:
string
)
=>
void
;
}
enum
StorageState
{
...
...
@@ -257,8 +256,8 @@ export class SQLiteStorageImpl {
return
this
.
all
(
db
,
'
SELECT * FROM ItemTable
'
).
then
(
rows
=>
{
rows
.
forEach
(
row
=>
items
.
set
(
row
.
key
,
row
.
value
));
if
(
this
.
logger
.
verbose
)
{
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] getItems():
${
mapToString
(
items
)}
`
);
if
(
this
.
logger
.
isTracing
)
{
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] getItems():
${
mapToString
(
items
)}
`
);
}
return
items
;
...
...
@@ -279,15 +278,15 @@ export class SQLiteStorageImpl {
return
Promise
.
resolve
();
}
if
(
this
.
logger
.
verbose
)
{
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] updateItems(): insert(
${
request
.
insert
?
mapToString
(
request
.
insert
)
:
'
0
'
}
), delete(
${
request
.
delete
?
setToString
(
request
.
delete
)
:
'
0
'
}
)`
);
if
(
this
.
logger
.
isTracing
)
{
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] updateItems(): insert(
${
request
.
insert
?
mapToString
(
request
.
insert
)
:
'
0
'
}
), delete(
${
request
.
delete
?
setToString
(
request
.
delete
)
:
'
0
'
}
)`
);
}
return
this
.
db
.
then
(
db
=>
{
return
this
.
transaction
(
db
,
()
=>
{
if
(
request
.
insert
&&
request
.
insert
.
size
>
0
)
{
this
.
prepare
(
db
,
'
INSERT INTO ItemTable VALUES (?,?)
'
,
stmt
=>
{
request
.
insert
!
.
forEach
((
value
,
key
)
=>
{
request
.
insert
.
forEach
((
value
,
key
)
=>
{
stmt
.
run
([
key
,
value
]);
});
});
...
...
@@ -295,7 +294,7 @@ export class SQLiteStorageImpl {
if
(
request
.
delete
&&
request
.
delete
.
size
)
{
this
.
prepare
(
db
,
'
DELETE FROM ItemTable WHERE key=?
'
,
stmt
=>
{
request
.
delete
!
.
forEach
(
key
=>
{
request
.
delete
.
forEach
(
key
=>
{
stmt
.
run
(
key
);
});
});
...
...
@@ -305,7 +304,7 @@ export class SQLiteStorageImpl {
}
close
():
Promise
<
void
>
{
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] close()`
);
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] close()`
);
return
this
.
db
.
then
(
db
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -323,7 +322,7 @@ export class SQLiteStorageImpl {
}
checkIntegrity
(
full
:
boolean
):
Promise
<
string
>
{
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] checkIntegrity(full:
${
full
}
)`
);
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] checkIntegrity(full:
${
full
}
)`
);
return
this
.
db
.
then
(
db
=>
{
return
this
.
get
(
db
,
full
?
'
PRAGMA integrity_check
'
:
'
PRAGMA quick_check
'
).
then
(
row
=>
{
...
...
@@ -333,7 +332,7 @@ export class SQLiteStorageImpl {
}
private
open
():
Promise
<
Database
>
{
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] open()`
);
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] open()`
);
return
new
Promise
((
resolve
,
reject
)
=>
{
const
fallbackToInMemoryDatabase
=
(
error
:
Error
)
=>
{
...
...
@@ -393,7 +392,7 @@ export class SQLiteStorageImpl {
mark
(
'
didRequireSQLite
'
);
}
const
db
=
new
(
this
.
logger
.
verbose
?
sqlite3
.
verbose
().
Database
:
sqlite3
.
Database
)(
path
,
error
=>
{
const
db
=
new
(
this
.
logger
.
isTracing
?
sqlite3
.
verbose
().
Database
:
sqlite3
.
Database
)(
path
,
error
=>
{
if
(
error
)
{
return
reject
(
error
);
}
...
...
@@ -420,13 +419,8 @@ export class SQLiteStorageImpl {
db
.
on
(
'
error
'
,
error
=>
this
.
logger
.
error
(
`[storage
${
this
.
name
}
] Error (event):
${
error
}
`
));
// Tracing
if
(
this
.
logger
.
trace
)
{
db
.
on
(
'
trace
'
,
sql
=>
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] Trace (event):
${
sql
}
`
));
}
// Profiling
if
(
this
.
logger
.
profile
)
{
db
.
on
(
'
profile
'
,
(
sql
,
time
)
=>
this
.
logger
.
info
(
`[storage
${
this
.
name
}
] Profile (event):
${
sql
}
(
${
time
}
ms)`
));
if
(
this
.
logger
.
isTracing
)
{
db
.
on
(
'
trace
'
,
sql
=>
this
.
logger
.
trace
(
`[storage
${
this
.
name
}
] Trace (event):
${
sql
}
`
));
}
});
});
...
...
@@ -516,35 +510,27 @@ export class SQLiteStorageImpl {
}
class
SQLiteStorageLogger
{
private
readonly
log
Info
:
boolean
;
private
readonly
log
Trace
:
boolean
;
private
readonly
logError
:
boolean
;
constructor
(
private
readonly
options
?:
IStorageLoggingOptions
)
{
this
.
logInfo
=
!!
(
this
.
verbose
&&
options
&&
options
.
infoLogger
);
this
.
logError
=
!!
(
options
&&
options
.
errorLogger
);
}
get
verbose
():
boolean
{
return
!!
(
this
.
options
&&
(
this
.
options
.
info
||
this
.
options
.
trace
||
this
.
options
.
profile
));
}
get
trace
():
boolean
{
return
!!
(
this
.
options
&&
this
.
options
.
trace
);
this
.
logTrace
=
!!
(
options
&&
options
.
logTrace
);
this
.
logError
=
!!
(
options
&&
options
.
logError
);
}
get
profile
():
boolean
{
return
!!
(
this
.
options
&&
this
.
options
.
profile
)
;
get
isTracing
():
boolean
{
return
this
.
logTrace
;
}
info
(
msg
:
string
):
void
{
if
(
this
.
log
Info
)
{
this
.
options
!
.
infoLogger
!
(
msg
);
trace
(
msg
:
string
):
void
{
if
(
this
.
log
Trace
)
{
this
.
options
.
logTrace
(
msg
);
}
}
error
(
error
:
string
|
Error
):
void
{
if
(
this
.
logError
)
{
this
.
options
!
.
errorLogger
!
(
error
);
this
.
options
.
logError
(
error
);
}
}
}
...
...
src/vs/base/test/node/storage/storage.test.ts
浏览文件 @
5f973bc6
...
...
@@ -205,11 +205,11 @@ suite('SQLite Storage Library', () => {
return
set
;
}
async
function
testDBBasics
(
path
,
errorLogge
r
?:
(
error
)
=>
void
)
{
async
function
testDBBasics
(
path
,
logErro
r
?:
(
error
)
=>
void
)
{
const
options
:
IStorageOptions
=
{
path
};
if
(
errorLogge
r
)
{
if
(
logErro
r
)
{
options
.
logging
=
{
errorLogge
r
logErro
r
};
}
...
...
src/vs/platform/storage/node/storageService.ts
浏览文件 @
5f973bc6
...
...
@@ -5,7 +5,7 @@
import
{
Disposable
,
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWorkspaceStorageChangeEvent
,
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Storage
,
IStorageLoggingOptions
,
NullStorage
,
IStorage
}
from
'
vs/base/node/storage
'
;
...
...
@@ -69,9 +69,9 @@ export class StorageService extends Disposable implements IStorageService {
super
();
this
.
loggingOptions
=
{
info
:
environmentService
.
verbos
e
,
infoLogger
:
msg
=>
logService
.
info
(
msg
),
errorLogge
r
:
error
=>
{
trace
:
logService
.
getLevel
()
===
LogLevel
.
Trac
e
,
logTrace
:
msg
=>
logService
.
trace
(
msg
),
logErro
r
:
error
=>
{
logService
.
error
(
error
);
this
.
_hasErrors
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录