mirror of
https://github.com/Tencent/MMKV.git
synced 2026-10-18 05:00:36 +08:00
fix tryAtomicRename() with src == dst bug
This commit is contained in:
@@ -72,6 +72,10 @@ bool tryAtomicRename(const MMKVPath_t &srcPath, const MMKVPath_t &dstPath) {
|
||||
MMKVWarning("fail on syscall(SYS_renameat2) [%s] to [%s], %d(%s)", srcPath.c_str(), dstPath.c_str(), errno,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (renamed && (srcPath != dstPath)) {
|
||||
::unlink(srcPath.c_str());
|
||||
}
|
||||
#endif // SYS_renameat2 && !MMKV_OHOS
|
||||
|
||||
if (!renamed) {
|
||||
@@ -81,7 +85,6 @@ bool tryAtomicRename(const MMKVPath_t &srcPath, const MMKVPath_t &dstPath) {
|
||||
}
|
||||
}
|
||||
|
||||
::unlink(srcPath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user