Defer deleting temporary repository files

Also don't propagate the error if deleting fails, just log it. If deleting fails, it doesn't break LOOT, it just uses up a little extra space until the next time the user runs disk cleanup or a similar utility, and temp dir clones are infrequent.
This commit is contained in:
Oliver Hamlet
2018-10-21 13:03:10 +01:00
parent 1fe8f901f0
commit 0bd12ed9a2
+10 -2
View File
@@ -235,10 +235,18 @@ void GitHelper::Clone(const std::filesystem::path& path,
}
for (const auto& filename : filenamesToMove) {
fs::rename(repoPath / filename, path / filename);
fs::copy(repoPath / filename, path / filename, std::filesystem::copy_options::recursive);
}
fs::remove_all(repoPath);
try {
fs::remove_all(repoPath);
} catch (std::exception& e) {
if (logger_) {
logger_->error(
"Could not delete temporary repository path \"{}\": {}",
repoPath.u8string(), e.what());
}
}
// Open the repo again.
Open(path);