Skip to content

Commit b33173a

Browse files
committed
File.Move doesn't overwrite targets
File.Move will throw an exception whenever the target file exists. Assuming that the task should overwrite the existing target files for smooth operation, this change checks whether the target file exists and, if so, deletes it prior to calling File.Move
1 parent e458e35 commit b33173a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/UnzipDirectoryChildren.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ async TTask ExtractFile (string tempDir, string sourceFile, string relativeDestD
112112
Log.LogMessage (MessageImportance.Low, $"mv '{fse}' '{dest}'");
113113
if (Directory.Exists (fse))
114114
Process.Start ("/bin/mv", $@"""{fse}"" ""{dest}""").WaitForExit ();
115-
else
115+
else {
116+
if (File.Exists (dest))
117+
File.Delete (dest);
116118
File.Move (fse, dest);
119+
}
117120
}
118121
}
119122
}

0 commit comments

Comments
 (0)