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

Don't stop for errors dumping invalid names or long names #375

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions src/zimdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ void write_to_error_directory(const std::string& base, const std::string relpath

if (stream.fail() || stream.bad()) {
std::cerr << "Error writing file to errors dir. " << (base + ERRORSDIR + url) << std::endl;
throw std::runtime_error(
std::string("Error writing file to errors dir. ") + (base + ERRORSDIR + url));
//throw std::runtime_error(
std::string("Error writing file to errors dir. ") + (base + ERRORSDIR + url);
Comment on lines +241 to +242
Copy link
Collaborator

Choose a reason for hiding this comment

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

Commenting the throw std::runtime_error( will just not throw the "error string".

But the std::string is still created for nothing.
Better remove the two lines.

} else {
std::cerr << "Wrote " << (base + relpath) << " to " << (base + ERRORSDIR + url) << std::endl;
}
Expand Down Expand Up @@ -321,8 +321,8 @@ void ZimDumper::dumpFiles(const std::string& directory, bool symlinkdump, std::f
write_to_file(directory + SEPARATOR, relative_path, blob.data(), blob.size());
#else
if (symlink(redirectPath.c_str(), full_path.c_str()) != 0) {
throw std::runtime_error(
std::string("Error creating symlink from ") + full_path + " to " + redirectPath);
//throw std::runtime_error(
std::string("Error creating symlink from ") + full_path + " to " + redirectPath;
Comment on lines +324 to +325
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this one.
Here we are failing to create a symlink. It can fails for a lot of reason. And even if we fail about a too long names, we must go through the error handling (and here, potentially print a warning only instead of failing if name is too long).

}
#endif
}
Expand Down Expand Up @@ -395,7 +395,7 @@ int subcmdDump(ZimDumper &app, std::map<std::string, docopt::value> &args)
std::string directory = args["--dir"].asString();

if (directory.empty()) {
throw std::runtime_error("Directory cannot be empty.");
//throw std::runtime_error("Directory cannot be empty.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. This test is used to not overwrite a existing content in the output directory.
We don't want to remove it.

}

if (directory.back() == '/'){
Expand Down
Loading