bug fix #228 : recover from corrupt BookTags.json
This commit is contained in:
parent
c95feebd39
commit
2e4c4cf5f7
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Version>6.7.5.1</Version>
|
<Version>6.7.6.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -54,11 +54,17 @@ namespace LibationFileManager
|
|||||||
|
|
||||||
private static void ensureCache()
|
private static void ensureCache()
|
||||||
{
|
{
|
||||||
if (cache is null)
|
if (cache is not null)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (locker)
|
lock (locker)
|
||||||
cache = !File.Exists(TagsFile)
|
{
|
||||||
? new Dictionary<string, string>()
|
if (File.Exists(TagsFile))
|
||||||
: JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(TagsFile));
|
cache = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(TagsFile));
|
||||||
|
|
||||||
|
// if file doesn't exist. or if file is corrupt and deserialize returns null
|
||||||
|
cache ??= new Dictionary<string, string>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user