File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,6 @@ bool sizeMatches(const fs::path& path, u64 initialSize) {
1818 return !initialSize || (initialSize == fs::file_size (path, dummy));
1919}
2020
21- void removeFile (const fs::path& path) noexcept {
22- std::error_code dummy;
23- fs::remove (path, dummy);
24- }
25-
2621} // namespace
2722
2823void fancyRename (const fs::path& src, const fs::path& dst) {
@@ -31,13 +26,12 @@ void fancyRename(const fs::path& src, const fs::path& dst) {
3126 // But this behavior is not obeyed by some Windows implementations (mingw/msys?)
3227 // In that case, we attempt to explicitly remove the destination beforehand
3328
34- try {
35- fs::rename (src, dst);
36- } catch (const fs::filesystem_error& e) {
37- removeFile (dst);
38-
39- // Retry the rename following destination removal above.
40- // If this rename does not succeed, let it out-throw.
29+ std::error_code error{};
30+ fs::rename (src, dst, error);
31+ if (error) {
32+ log (" rename %s -> %s error %s, trying remove\n " ,
33+ src.string ().c_str (), dst.string ().c_str (), error.message ().c_str ());
34+ fs::remove (dst);
4135 fs::rename (src, dst);
4236 }
4337}
You can’t perform that action at this time.
0 commit comments