safe-fail if old file can't be deleted
This commit is contained in:
@@ -25,6 +25,7 @@ public static class Utils
|
||||
var triesLeft = 1;
|
||||
var srcFileName = sourceFile.FullName;
|
||||
var destFileName = destinationFile.FullName;
|
||||
string? oldFile = null;
|
||||
|
||||
while (triesLeft > 0)
|
||||
{
|
||||
@@ -38,9 +39,8 @@ public static class Utils
|
||||
{
|
||||
if (triesLeft == 0 && File.Exists(destFileName))
|
||||
{
|
||||
var oldFile = destFileName + ".old";
|
||||
oldFile = destFileName + ".old";
|
||||
File.Move(destFileName, oldFile, true);
|
||||
File.Delete(oldFile);
|
||||
triesLeft++;
|
||||
}
|
||||
}
|
||||
@@ -48,5 +48,16 @@ public static class Utils
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (oldFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(oldFile);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user