mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-25 00:53:43 +00:00
Skip mime errors if user passed --ignore-errors.
This commit is contained in:
parent
2318bc01ee
commit
106b72bf0e
3 changed files with 14 additions and 7 deletions
|
@ -31,7 +31,7 @@ namespace mchlib {
|
|||
public:
|
||||
using DirTreeTaskPtr = std::shared_ptr<Base<std::vector<FileRecordData>>>;
|
||||
|
||||
explicit Mime ( DirTreeTaskPtr parDirTree );
|
||||
Mime (DirTreeTaskPtr parDirTree, bool parIgnoreErrors);
|
||||
virtual ~Mime ( void ) noexcept;
|
||||
|
||||
private:
|
||||
|
@ -39,6 +39,7 @@ namespace mchlib {
|
|||
virtual std::vector<FileRecordData>& on_data_get ( void ) override;
|
||||
|
||||
DirTreeTaskPtr m_file_tree_task;
|
||||
bool m_ignore_errors;
|
||||
};
|
||||
} //namespace scantask
|
||||
} //namespace mchlib
|
||||
|
|
|
@ -25,8 +25,9 @@ namespace mchlib {
|
|||
} //unnamed namespace
|
||||
|
||||
namespace scantask {
|
||||
Mime::Mime (DirTreeTaskPtr parDirTree) :
|
||||
m_file_tree_task(parDirTree)
|
||||
Mime::Mime (DirTreeTaskPtr parDirTree, bool parIgnoreErrors) :
|
||||
m_file_tree_task(parDirTree),
|
||||
m_ignore_errors(parIgnoreErrors)
|
||||
{
|
||||
assert(m_file_tree_task);
|
||||
}
|
||||
|
@ -39,10 +40,15 @@ namespace mchlib {
|
|||
auto& list = m_file_tree_task->get_or_create();
|
||||
|
||||
for (auto& itm : list) {
|
||||
try {
|
||||
itm.mime_full = mime.analyze(itm.abs_path);
|
||||
auto mime_pair = split_mime(itm.mime_full);
|
||||
itm.set_mime_parts(mime_pair.first, mime_pair.second);
|
||||
}
|
||||
catch (const std::runtime_error&) {
|
||||
itm.mime_full = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FileRecordData>& Mime::on_data_get() {
|
||||
|
|
|
@ -91,7 +91,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
std::shared_ptr<stask::MediaType> media_type(new stask::MediaType(setbasic, def_media_type, vm.count("type"), search_path));
|
||||
std::shared_ptr<stask::Hashing> hashing(new stask::Hashing(scan_dirtree, ignore_read_errors));
|
||||
std::shared_ptr<stask::ContentType> content_type(new stask::ContentType(setbasic, scan_dirtree, media_type));
|
||||
std::shared_ptr<stask::Mime> mime(new stask::Mime(scan_dirtree));
|
||||
std::shared_ptr<stask::Mime> mime(new stask::Mime(scan_dirtree, ignore_read_errors));
|
||||
std::shared_ptr<FileRecordDataFiller> filerecdata(new FileRecordDataFiller(mime, hashing));
|
||||
std::shared_ptr<SetRecordDataFiller> setrecdata(new SetRecordDataFiller(media_type, content_type));
|
||||
|
||||
|
|
Loading…
Reference in a new issue