Skip to content

Commit

Permalink
Sink and log initialization error (#454)
Browse files Browse the repository at this point in the history
Fix for #453
  • Loading branch information
PiDiBi committed Jun 13, 2023
1 parent 14bd379 commit c947aa9
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/CopyOnWrite/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,17 +1023,25 @@ private bool IsCopyOnWriteSupported(string source, string dest)
return false;
}

return _reFsDrives.GetOrAdd(
sourceDrive,
(key) => new Lazy<bool>(() =>
{
var supportsCloneFile = _cow.CopyOnWriteLinkSupportedInDirectoryTree(key);
Log.LogMessage(MessageImportance.Low,
supportsCloneFile
? $"Drive {key} has support for CloneFile. All copies will attempt to use CloneFile."
: $"Drive {key} does not have support for CloneFile. File.Copy will be used.");
return supportsCloneFile;
})).Value;
try
{
return _reFsDrives.GetOrAdd(
sourceDrive,
(key) => new Lazy<bool>(() =>
{
var supportsCloneFile = _cow.CopyOnWriteLinkSupportedInDirectoryTree(key);
Log.LogMessage(MessageImportance.Low,
supportsCloneFile
? $"Drive {key} has support for CloneFile. All copies will attempt to use CloneFile."
: $"Drive {key} does not have support for CloneFile. File.Copy will be used.");
return supportsCloneFile;
})).Value;
}
catch (Exception ex)
{
Log.LogMessage(MessageImportance.Low, $"Couldn't determine if CloneFile is supported for {sourceDrive} : {ex}");
return false;
}
}
#endregion
}
Expand Down

0 comments on commit c947aa9

Please sign in to comment.