Skip to content

Commit

Permalink
Merge pull request #29 from fiddyschmitt/28-systemoutofmemoryexceptio…
Browse files Browse the repository at this point in the history
…n-during-setpartclonecontentmapping

Add exception handling to cache methods
  • Loading branch information
fiddyschmitt authored Jan 1, 2023
2 parents 68b6d60 + 4a2bcbb commit 61e6abe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clonezilla-util/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace clonezilla_util
public class Program
{
const string PROGRAM_NAME = "clonezilla-util";
const string PROGRAM_VERSION = "2.0.3";
const string PROGRAM_VERSION = "2.0.4";

private enum ReturnCode
{
Expand Down
23 changes: 19 additions & 4 deletions libClonezilla/Cache/PartitionCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using lib7Zip;
using libDokan.VFS.Files;
using libDokan.VFS.Folders;
using Serilog;

namespace libClonezilla.Cache
{
Expand Down Expand Up @@ -54,8 +55,15 @@ public string GetGztoolIndexFilename()

public void SetPartcloneContentMapping(List<ContiguousRange> contiguousRanges)
{
var json = JsonConvert.SerializeObject(contiguousRanges, Formatting.Indented);
File.WriteAllText(PartcloneContentMappingFilename, json);
try
{
var json = JsonConvert.SerializeObject(contiguousRanges, Formatting.Indented);
File.WriteAllText(PartcloneContentMappingFilename, json);
}
catch (Exception ex)
{
Log.Warning($"Non-fatal. Error while caching Partclone Content Mapping to {PartcloneContentMappingFilename}: {ex}");
}
}

public List<ArchiveEntry>? GetFileList()
Expand All @@ -73,8 +81,15 @@ public void SetPartcloneContentMapping(List<ContiguousRange> contiguousRanges)

public void SetFileList(List<ArchiveEntry> filenames)
{
var json = JsonConvert.SerializeObject(filenames, Formatting.Indented);
File.WriteAllText(FileListFilename, json);
try
{
var json = JsonConvert.SerializeObject(filenames, Formatting.Indented);
File.WriteAllText(FileListFilename, json);
}
catch (Exception ex)
{
Log.Warning($"Non-fatal. Error while caching File List to {FileListFilename}: {ex}");
}
}
}
}

0 comments on commit 61e6abe

Please sign in to comment.