Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 01020a9

Browse files
committed
Make sure ToFile overwrites any existing file
1 parent c5e39b1 commit 01020a9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/GitHub.Api/Helpers/AssemblyResources.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Each file's name is their physical path in the project.
2828
If the resource is still not found, it attempts to find it in the file system
2929
*/
3030

31+
var target = destinationPath.Combine(resource);
3132
var os = "";
3233
if (resourceType == ResourceType.Platform)
3334
{
@@ -46,7 +47,10 @@ Each file's name is their physical path in the project.
4647
var stream = asm.GetManifestResourceStream(
4748
String.Format("GitHub.Unity.{0}{1}.{2}", type, !string.IsNullOrEmpty(os) ? "." + os : os, resource));
4849
if (stream != null)
49-
return destinationPath.Combine(resource).WriteAllBytes(stream.ToByteArray());
50+
{
51+
target.DeleteIfExists();
52+
return target.WriteAllBytes(stream.ToByteArray());
53+
}
5054

5155
// if we're not in the test runner, we might be running in a Unity-compiled GitHub.Unity assembly, which doesn't
5256
// embed the resources in the assembly
@@ -55,7 +59,10 @@ Each file's name is their physical path in the project.
5559
// check the filesystem
5660
NPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource);
5761
if (possiblePath.FileExists())
58-
return possiblePath.Copy(destinationPath.Combine(resource));
62+
{
63+
target.DeleteIfExists();
64+
return possiblePath.Copy(target);
65+
}
5966
}
6067
return NPath.Default;
6168
}

0 commit comments

Comments
 (0)