Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6db1e07b
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6db1e07b
编写于
3月 18, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
If we fail to create the sqlite db, don't continually retry for every client that wants it.
上级
87c9fff2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
37 deletion
+26
-37
src/Workspaces/Core/Portable/Storage/AbstractPersistentStorageService.cs
...Core/Portable/Storage/AbstractPersistentStorageService.cs
+26
-37
未找到文件。
src/Workspaces/Core/Portable/Storage/AbstractPersistentStorageService.cs
浏览文件 @
6db1e07b
...
...
@@ -20,7 +20,6 @@ namespace Microsoft.CodeAnalysis.Storage
/// </summary>
internal
abstract
partial
class
AbstractPersistentStorageService
:
IChecksummedPersistentStorageService
{
private
readonly
IOptionService
_optionService
;
private
readonly
IPersistentStorageLocationService
_locationService
;
/// <summary>
...
...
@@ -30,13 +29,8 @@ internal abstract partial class AbstractPersistentStorageService : IChecksummedP
private
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
_currentPersistentStorage
;
private
SolutionId
_currentPersistentStorageSolutionId
;
protected
AbstractPersistentStorageService
(
IOptionService
optionService
,
IPersistentStorageLocationService
locationService
)
{
_optionService
=
optionService
;
_locationService
=
locationService
;
}
protected
AbstractPersistentStorageService
(
IPersistentStorageLocationService
locationService
)
=>
_locationService
=
locationService
;
protected
abstract
string
GetDatabaseFilePath
(
string
workingFolderPath
);
protected
abstract
bool
TryOpenDatabase
(
Solution
solution
,
string
workingFolderPath
,
string
databaseFilePath
,
out
IChecksummedPersistentStorage
storage
);
...
...
@@ -68,7 +62,8 @@ internal IChecksummedPersistentStorage GetStorageWorker(Solution solution)
// Do we already have storage for this?
if
(
solution
.
Id
==
_currentPersistentStorageSolutionId
)
{
// We do, great
// We do, great up our ref count for our caller. They'll decrement it when done
// with it.
return
PersistentStorageReferenceCountedDisposableWrapper
.
AddReferenceCountToAndCreateWrapper
(
_currentPersistentStorage
);
}
...
...
@@ -83,21 +78,27 @@ internal IChecksummedPersistentStorage GetStorageWorker(Solution solution)
{
var
storageToDispose
=
_currentPersistentStorage
;
// Kick off a task to actually go dispose the previous cached storage instance.
// This will remove the single ref count we ourselves added when we cached the
// instance. Then once all other existing clients who are holding onto this
// instance let go, it will finally get truly disposed.
Task
.
Run
(()
=>
storageToDispose
.
Dispose
());
_currentPersistentStorage
=
null
;
_currentPersistentStorageSolutionId
=
null
;
}
_currentPersistentStorage
=
TryCreatePersistentStorage
(
solution
,
workingFolder
);
if
(
_currentPersistentStorage
==
null
)
{
return
NoOpPersistentStorage
.
Instance
;
}
var
storage
=
CreatePersistentStorage
(
solution
,
workingFolder
);
Contract
.
ThrowIfNull
(
storage
);
// Create and cache a new storage instance associated with this particular solution.
// It will initially have a ref-count of 1 due to our reference to it.
_currentPersistentStorage
=
new
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>(
storage
);
_currentPersistentStorageSolutionId
=
solution
.
Id
;
// Now increment the reference count and return to our caller. The current ref
// count for this instance will be 2. Until all the callers *and* us decrement
// the refcounts, this instance will not be actually disposed.
return
PersistentStorageReferenceCountedDisposableWrapper
.
AddReferenceCountToAndCreateWrapper
(
_currentPersistentStorage
);
}
}
...
...
@@ -118,39 +119,27 @@ private bool DatabaseSupported(Solution solution, bool checkBranchId)
return
true
;
}
private
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>
Try
CreatePersistentStorage
(
Solution
solution
,
string
workingFolderPath
)
private
IChecksummedPersistentStorage
CreatePersistentStorage
(
Solution
solution
,
string
workingFolderPath
)
{
// Attempt to create the database up to two times. The first time we may encounter
// some sort of issue (like DB corruption). We'll then try to delete the DB and can
// try to create it again. If we can't create it the second time, then there's nothing
// we can do and we have to store things in memory.
if
(
TryCreatePersistentStorage
(
solution
,
workingFolderPath
,
out
var
persistentStorage
)
||
TryCreatePersistentStorage
(
solution
,
workingFolderPath
,
out
persistentStorage
))
{
return
new
ReferenceCountedDisposable
<
IChecksummedPersistentStorage
>(
persistentStorage
);
}
// okay, can't recover, then use no op persistent service
// so that things works old way (cache everything in memory)
return
null
;
return
TryCreatePersistentStorage
(
solution
,
workingFolderPath
)
??
TryCreatePersistentStorage
(
solution
,
workingFolderPath
)
??
NoOpPersistentStorage
.
Instance
;
}
private
bool
TryCreatePersistentStorage
(
private
IChecksummedPersistentStorage
?
TryCreatePersistentStorage
(
Solution
solution
,
string
workingFolderPath
,
out
IChecksummedPersistentStorage
persistentStorage
)
string
workingFolderPath
)
{
persistentStorage
=
null
;
var
databaseFilePath
=
GetDatabaseFilePath
(
workingFolderPath
);
try
{
if
(!
TryOpenDatabase
(
solution
,
workingFolderPath
,
databaseFilePath
,
out
persistentStorage
))
{
return
false
;
}
return
true
;
return
TryOpenDatabase
(
solution
,
workingFolderPath
,
databaseFilePath
,
out
var
persistentStorage
)
?
persistentStorage
:
null
;
}
catch
(
Exception
ex
)
{
...
...
@@ -164,7 +153,7 @@ private ReferenceCountedDisposable<IChecksummedPersistentStorage> TryCreatePersi
IOUtilities
.
PerformIO
(()
=>
Directory
.
Delete
(
Path
.
GetDirectoryName
(
databaseFilePath
),
recursive
:
true
));
}
return
false
;
return
null
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录