mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
Added file length check before loading cache and removed BinaryStorage.Save when file was already locked.
This commit is contained in:
@@ -30,19 +30,17 @@ namespace Wox.Infrastructure.Storage
|
|||||||
{
|
{
|
||||||
if (File.Exists(FilePath))
|
if (File.Exists(FilePath))
|
||||||
{
|
{
|
||||||
|
if (new FileInfo(FilePath).Length == 0)
|
||||||
|
{
|
||||||
|
Log.Error($"|BinaryStorage.TryLoad|Zero length cache file <{FilePath}>");
|
||||||
|
Save(defaultData);
|
||||||
|
return defaultData;
|
||||||
|
}
|
||||||
|
|
||||||
using (var stream = new FileStream(FilePath, FileMode.Open))
|
using (var stream = new FileStream(FilePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
if (stream.Length > 0)
|
var d = Deserialize(stream, defaultData);
|
||||||
{
|
return d;
|
||||||
var d = Deserialize(stream, defaultData);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Error($"|BinaryStorage.TryLoad|Zero length cache file <{FilePath}>");
|
|
||||||
Save(defaultData);
|
|
||||||
return defaultData;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user