1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-02-16 11:35:49 +00:00

Skip mime errors if user passed --ignore-errors.

This commit is contained in:
King_DuckZ 2017-08-12 21:33:57 +01:00
parent 2318bc01ee
commit 106b72bf0e
3 changed files with 14 additions and 7 deletions

View file

@ -31,7 +31,7 @@ namespace mchlib {
public: public:
using DirTreeTaskPtr = std::shared_ptr<Base<std::vector<FileRecordData>>>; using DirTreeTaskPtr = std::shared_ptr<Base<std::vector<FileRecordData>>>;
explicit Mime ( DirTreeTaskPtr parDirTree ); Mime (DirTreeTaskPtr parDirTree, bool parIgnoreErrors);
virtual ~Mime ( void ) noexcept; virtual ~Mime ( void ) noexcept;
private: private:
@ -39,6 +39,7 @@ namespace mchlib {
virtual std::vector<FileRecordData>& on_data_get ( void ) override; virtual std::vector<FileRecordData>& on_data_get ( void ) override;
DirTreeTaskPtr m_file_tree_task; DirTreeTaskPtr m_file_tree_task;
bool m_ignore_errors;
}; };
} //namespace scantask } //namespace scantask
} //namespace mchlib } //namespace mchlib

View file

@ -25,8 +25,9 @@ namespace mchlib {
} //unnamed namespace } //unnamed namespace
namespace scantask { namespace scantask {
Mime::Mime (DirTreeTaskPtr parDirTree) : Mime::Mime (DirTreeTaskPtr parDirTree, bool parIgnoreErrors) :
m_file_tree_task(parDirTree) m_file_tree_task(parDirTree),
m_ignore_errors(parIgnoreErrors)
{ {
assert(m_file_tree_task); assert(m_file_tree_task);
} }
@ -39,9 +40,14 @@ namespace mchlib {
auto& list = m_file_tree_task->get_or_create(); auto& list = m_file_tree_task->get_or_create();
for (auto& itm : list) { for (auto& itm : list) {
itm.mime_full = mime.analyze(itm.abs_path); try {
auto mime_pair = split_mime(itm.mime_full); itm.mime_full = mime.analyze(itm.abs_path);
itm.set_mime_parts(mime_pair.first, mime_pair.second); 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 = "";
}
} }
} }

View file

@ -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::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::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::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<FileRecordDataFiller> filerecdata(new FileRecordDataFiller(mime, hashing));
std::shared_ptr<SetRecordDataFiller> setrecdata(new SetRecordDataFiller(media_type, content_type)); std::shared_ptr<SetRecordDataFiller> setrecdata(new SetRecordDataFiller(media_type, content_type));