mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #20519: Handle rename failure in DumpMempool(...) by using the RenameOver(...) return value. Add [[nodiscard]] to RenameOver(...).
ce9dd45422e1f4ecce6df68da086b8bfc2100756 Add [[nodiscard]] to RenameOver(...) (practicalswift)
9429a398e291a1b5edcfc657b94fcaf52cd1d8f9 Handle rename failure in DumpMempool(...) by using RenameOver(...) return value (practicalswift)
Pull request description:
Handle rename failure in `DumpMempool(...)` by using the `RenameOver(...)` return value.
Add `[[nodiscard]]` to `RenameOver(...)` to reduce the risk of similar rename issues in the future.
ACKs for top commit:
vasild:
ACK ce9dd454
theStack:
ACK ce9dd45422e1f4ecce6df68da086b8bfc2100756 🏷️
Tree-SHA512: 1e63d7f3061e1f6ea2df5750dbc1547a39bd50b6c529812a0c8a0c11d3100c241afdf14094e69b69a38bade7e54a12b2a42888545874398eaf5d02421b57e874
This commit is contained in:
parent
2328ead832
commit
4d8f035207
@ -898,7 +898,9 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
|
||||
fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
LogPrintf("Importing bootstrap.dat...\n");
|
||||
LoadExternalBlockFile(chainparams, file);
|
||||
RenameOver(pathBootstrap, pathBootstrapOld);
|
||||
if (!RenameOver(pathBootstrap, pathBootstrapOld)) {
|
||||
throw std::runtime_error("Rename failed");
|
||||
}
|
||||
} else {
|
||||
LogPrintf("Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ bool FileCommit(FILE *file);
|
||||
bool TruncateFile(FILE *file, unsigned int length);
|
||||
int RaiseFileDescriptorLimit(int nMinFD);
|
||||
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
|
||||
bool RenameOver(fs::path src, fs::path dest);
|
||||
[[nodiscard]] bool RenameOver(fs::path src, fs::path dest);
|
||||
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false);
|
||||
void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name);
|
||||
bool DirIsWritable(const fs::path& directory);
|
||||
|
@ -5247,7 +5247,9 @@ bool DumpMempool()
|
||||
if (!FileCommit(file.Get()))
|
||||
throw std::runtime_error("FileCommit failed");
|
||||
file.fclose();
|
||||
RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat");
|
||||
if (!RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat")) {
|
||||
throw std::runtime_error("Rename failed");
|
||||
}
|
||||
int64_t last = GetTimeMicros();
|
||||
LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", (mid-start)*MICRO, (last-mid)*MICRO);
|
||||
} catch (const std::exception& e) {
|
||||
|
Loading…
Reference in New Issue
Block a user