Skip to content
This repository was archived by the owner on Dec 22, 2019. It is now read-only.

Commit bf7910c

Browse files
committed
Auto recovers the HashCacheFile if it is corrupt instead of crashing.
1 parent d740080 commit bf7910c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

UpdateLib/UpdateLib/Tasks/UpdateCacheTask.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ public class UpdateCacheTask : AsyncTask<HashCacheFile>
1111
{
1212
protected override void DoWork()
1313
{
14-
// first of lets load the file
15-
Result = HashCacheFile.Load();
14+
try
15+
{
16+
// first of lets load the file, (file might be corrupt..)
17+
Result = HashCacheFile.Load();
18+
}
19+
catch (Exception e)
20+
{
21+
Logger.Error(GetType().Name, e);
22+
Result = null;
23+
}
1624

1725
DirectoryInfo dir = new DirectoryInfo(".");
1826
IEnumerable<FileInfo> files = dir.GetFiles("*", SearchOption.AllDirectories).Where(f => !f.FullName.Contains(".old.tmp"));
19-
20-
27+
2128
Logger.Debug(GetType().Name, $"found {files.Count()} files to recheck.");
2229

2330
if (Result == null) // The file doesn't exist yet

0 commit comments

Comments
 (0)