mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user