Merge pull request #1776 from lances101/feature/cache-being-used

#1394 caching fix
This commit is contained in:
Boris Makogonyuk 2017-12-22 17:05:31 +01:00 committed by GitHub
commit 3aacfdca20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,19 +30,17 @@ namespace Wox.Infrastructure.Storage
{
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))
{
if (stream.Length > 0)
{
var d = Deserialize(stream, defaultData);
return d;
}
else
{
Log.Error($"|BinaryStorage.TryLoad|Zero length cache file <{FilePath}>");
Save(defaultData);
return defaultData;
}
var d = Deserialize(stream, defaultData);
return d;
}
}
else