Browse Source

Prevent file corruption

pull/100/head
Meivyn 1 year ago
parent
commit
54b0dd360b
No known key found for this signature in database GPG Key ID: 8BDD3E48158B2F71
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      IPA.Injector/Injector.cs

+ 9
- 3
IPA.Injector/Injector.cs View File

@ -247,8 +247,11 @@ namespace IPA.Injector
if (modified) if (modified)
{ {
string tempFilePath = Path.GetTempFileName();
bkp?.Add(unityPath); bkp?.Add(unityPath);
unityAsmDef.Write(unityPath);
unityAsmDef.Write(tempFilePath);
File.Delete(unityPath);
File.Move(tempFilePath, unityPath);
} }
} }
endPatchCoreModule: endPatchCoreModule:
@ -279,7 +282,10 @@ namespace IPA.Injector
var deleter = ascModDef.GetType("IPAPluginsDirDeleter"); var deleter = ascModDef.GetType("IPAPluginsDirDeleter");
deleter.Methods.Clear(); // delete all methods deleter.Methods.Clear(); // delete all methods
ascAsmDef.Write(ascPath);
string tempFilePath = Path.GetTempFileName();
ascAsmDef.Write(tempFilePath);
File.Delete(ascPath);
File.Move(tempFilePath, ascPath);
isFirst = false; isFirst = false;
} }
@ -333,4 +339,4 @@ namespace IPA.Injector
_ = PluginComponent.Create(); _ = PluginComponent.Create();
} }
} }
}
}

Loading…
Cancel
Save