mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-06 09:20:33 +00:00
download: atomically move tempfile when possible
should save unnecessary time and I/O and eliminate the possibility of the file being improperly truncated when the temp file is on the same filesystem as the destination path
This commit is contained in:
parent
eafb98b3a9
commit
1f371be395
@ -286,6 +286,14 @@ void HashAndSaveFile::hashAndSave(const QString &expectedHash, const QString &sa
|
||||
// The file save needs the tempFile closed
|
||||
tempFile->close();
|
||||
|
||||
// Attempt to *move* the verified tempfile into place - this should be atomic
|
||||
// but will only work if the destination is on the same filesystem
|
||||
if (tempFile->rename(saveFilePath)) {
|
||||
tempFile->setAutoRemove(false);
|
||||
emit hashAndSaveFinished(true, tempFile, modelReply);
|
||||
return;
|
||||
}
|
||||
|
||||
// Reopen the tempFile for copying
|
||||
if (!tempFile->open()) {
|
||||
qWarning() << "ERROR: Could not open temp file at finish:"
|
||||
|
Loading…
Reference in New Issue
Block a user