Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move final file if in same file system, not only in same directory #211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ build
.mypy_cache
*.whl
venv
/.vs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this deliberate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual Studio added it, and I thought since .vscode is already in there I can include it

36 changes: 23 additions & 13 deletions src/plotter_disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,31 @@ class DiskPlotter {
}
} else {
if (!bCopied) {
fs::copy(
tmp_2_filename, final_2_filename, fs::copy_options::overwrite_existing, ec);
fs::rename(tmp_2_filename, final_filename, ec);
if (ec.value() != 0) {
std::cout << "Could not copy " << tmp_2_filename << " to "
<< final_2_filename << ". Error " << ec.message()
<< ". Retrying in five minutes." << std::endl;
fs::copy(
tmp_2_filename,
final_2_filename,
fs::copy_options::overwrite_existing,
ec);
if (ec.value() != 0) {
std::cout << "Could not copy " << tmp_2_filename << " to "
<< final_2_filename << ". Error " << ec.message()
<< ". Retrying in five minutes." << std::endl;
} else {
std::cout << "Copied final file from " << tmp_2_filename << " to "
<< final_2_filename << std::endl;
copy.PrintElapsed("Copy time =");
bCopied = true;

bool removed_2 = fs::remove(tmp_2_filename);
std::cout << "Removed temp2 file " << tmp_2_filename << "? "
<< removed_2 << std::endl;
}
} else {
std::cout << "Copied final file from " << tmp_2_filename << " to "
<< final_2_filename << std::endl;
copy.PrintElapsed("Copy time =");
bCopied = true;

bool removed_2 = fs::remove(tmp_2_filename);
std::cout << "Removed temp2 file " << tmp_2_filename << "? " << removed_2
<< std::endl;
bRenamed = true;
std::cout << "Renamed final file from " << tmp_2_filename << " to "
<< final_filename << std::endl;
}
}
if (bCopied && (!bRenamed)) {
Expand Down