Skip in-epub file if it is not found, except it's the container.

We skipped the whole EPUB before.
This commit is contained in:
tastytea 2021-05-29 18:12:56 +02:00
parent 5bd1030ad8
commit ba5716c585
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 13 additions and 1 deletions

View File

@ -39,6 +39,7 @@ namespace epubgrep::zip
using boost::locale::translate;
using fmt::format;
using std::cerr;
std::vector<std::string> list(const fs::path &filepath)
{
@ -112,8 +113,19 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
close_file(zipfile, filepath);
throw exception{format(translate("{0:s} not found in {1:s}.").str(),
if (entry_path == "META-INF/container.xml")
{ // File is probably not an EPUB.
exception e{format(translate("{0:s} not found in {1:s}.").str(),
entry_path, filepath.string())};
e.code = 1;
throw exception{e};
}
cerr << translate("WARNING: ")
<< format(translate("{0:s} not found in {1:s}.").str(), entry_path,
filepath.string())
<< '\n';
return {};
}
struct archive *open_file(const fs::path &filepath)