summaryrefslogtreecommitdiff
path: root/Source/Core/UpdaterCommon/UpdaterCommon.cpp
diff options
context:
space:
mode:
authorOatmealDome <julian@oatmealdome.me>2021-07-09 12:56:23 -0400
committerOatmealDome <julian@oatmealdome.me>2021-07-09 12:56:23 -0400
commita39b7a45c0609771496936fadee6eb016447851c (patch)
tree6767c77d7af260721660b053182e643a7021ea6b /Source/Core/UpdaterCommon/UpdaterCommon.cpp
parentcfcc994f6c6966172c108ee73347d7ad3f0ae717 (diff)
UpdaterCommon: Use File::Copy() on non-macOS platforms
Diffstat (limited to 'Source/Core/UpdaterCommon/UpdaterCommon.cpp')
-rw-r--r--Source/Core/UpdaterCommon/UpdaterCommon.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp
index 791f501151..74665bf4c1 100644
--- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp
+++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp
@@ -430,7 +430,16 @@ bool UpdateFiles(const std::vector<TodoList::UpdateOp>& to_update,
std::string content_filename = HexEncode(op.new_hash.data(), op.new_hash.size());
fprintf(log_fp, "Updating file %s from content %s...\n", op.filename.c_str(),
content_filename.c_str());
+#ifdef __APPLE__
+ // macOS caches the code signature of Mach-O executables when they're first loaded.
+ // Unfortunately, there is a quirk in the kernel with how it handles the cache: if the file is
+ // simply overwritten, the cache isn't invalidated and the old code signature is used to verify
+ // the new file. This causes macOS to kill the process with a code signing error. To workaround
+ // this, we use File::Rename() instead of File::Copy().
if (!File::Rename(temp_path + DIR_SEP + content_filename, path))
+#else
+ if (!File::Copy(temp_path + DIR_SEP + content_filename, path))
+#endif
{
fprintf(log_fp, "Could not update file %s.\n", op.filename.c_str());
return false;