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

using filesystem read_link to test if sym link already created. #417

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nickhuang99
Copy link

  1. using std::filesystem's read_link.
  2. This is an improvement so only test when failure to avoid expensive system call.
  3. Hopefully this avoid race condition.

Copy link
Collaborator

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

On code side, only a small change needed.

On the functionality itself, I'm a bit reluctant as we should not have this kind of situation. If symlinks already exist, there is a lot of probability that contents already exist too. Only checking for symlink is useless here. And if we overwrite content/symlink we should probably have a option at command line level to allow it.

But anyway, even with my concerns, I don't see how this can harm so I will not block this PR.

@@ -291,6 +292,16 @@ void ZimDumper::writeHttpRedirect(const std::string& directory, const std::strin
write_to_file(directory + SEPARATOR, outputPath, content.c_str(), content.size());
}

inline static bool testSymLink(const std::string& sym, const std::string& target) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

testSymlink convey very few information. (What is tested ?)

It would be better to rename it to checkSymlinkTarget or symlinkPointsTo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants