Skip to content

Commit

Permalink
store: can not rename to existing filename on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Oct 26, 2022
1 parent f0de898 commit 5c925c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/store.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "config.h"

#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
Expand Down Expand Up @@ -104,6 +106,11 @@ hsk_store_write(hsk_checkpoint_t *checkpoint, char *prefix) {
if (written != HSK_STORE_CHECKPOINT_SIZE)
return false;

#if defined(_WIN32)
// Can not do the rename-file trick to guarantee atomicity on windows
remove(path);
#endif

return rename(tmp, path) == 0;
}

Expand Down

0 comments on commit 5c925c4

Please sign in to comment.