Skip to content

Commit

Permalink
Better recovery when registry.json is corrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Apr 17, 2021
1 parent 6b2340c commit ae43435
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Core/Registry/RegistryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ private void LoadOrCreate()
Create();
Load();
}
catch (JsonException exc)
{
var corruptPath = path + "_CORRUPTED_" + DateTime.Now.ToString("yyyyMMddHHmmss");
log.ErrorFormat("{0} is corrupted, archiving to {1}: {2}",
path, corruptPath, exc.Message);
File.Move(path, corruptPath);
Create();
Load();
}
catch (Exception ex)
{
log.ErrorFormat("Uncaught exception loading registry: {0}", ex.ToString());
Expand Down

0 comments on commit ae43435

Please sign in to comment.