Correctly set the zimPathToSave if there are several zim file to add.

The variable `zimPathToSave` is used to store the option passed by the
user.
If we reuse this variable to store the real path to use for the first
zim file, then we will mess the path to save of other zim files.

Let's use a local variable here.

Fix #288
This commit is contained in:
Matthieu Gautier 2019-05-03 12:08:08 +02:00
parent 6eace310a2
commit 4de8623a52

View File

@ -173,8 +173,8 @@ bool handle_add(kiwix::Library* library, const std::string& libraryPath,
for(auto i=optind; i<argc; i++) { for(auto i=optind; i<argc; i++) {
std::string zimPath = argv[i]; std::string zimPath = argv[i];
if (!zimPath.empty()) { if (!zimPath.empty()) {
zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave; auto _zimPathToSave = zimPathToSave == "." ? zimPath : zimPathToSave;
manager.addBookFromPathAndGetId(zimPath, zimPathToSave, url, false); manager.addBookFromPathAndGetId(zimPath, _zimPathToSave, url, false);
} else { } else {
std::cerr << "Invalid zim file path" << std::endl; std::cerr << "Invalid zim file path" << std::endl;
resultCode = 1; resultCode = 1;