diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-06-25 22:34:47 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-06-25 22:34:48 +0200 |
| commit | aff5f8916b50f458a066306f757e44557542c192 (patch) | |
| tree | 4d9f5a1b95cb1956f789c599da445fcf334dc30d | |
| parent | 995dcccd62983c95d2a50dd237ba20b2a89d6024 (diff) | |
Tolerate problems when reading the contents of DCPs.
This avoids errors in cases like unreadable lost+found directories
appearing inside a DCP.
| -rw-r--r-- | src/lib/dcp_content.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index e2b19fb8e..442b5bd40 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -50,6 +50,7 @@ using std::cout; using std::dynamic_pointer_cast; +using std::exception; using std::function; using std::list; using std::make_shared; @@ -197,16 +198,20 @@ DCPContent::read_sub_directory (boost::filesystem::path p) using namespace boost::filesystem; LOG_GENERAL ("DCPContent::read_sub_directory reads %1", p.string()); - for (auto i: directory_iterator(p)) { - if (is_regular_file(i.path())) { - LOG_GENERAL ("Inside there's regular file %1", i.path().string()); - add_path (i.path()); - } else if (is_directory(i.path()) && i.path().filename() != ".AppleDouble") { - LOG_GENERAL ("Inside there's directory %1", i.path().string()); - read_sub_directory (i.path()); - } else { - LOG_GENERAL("Ignoring %1 from inside: status is %2", i.path().string(), static_cast<int>(status(i.path()).type())); + try { + for (auto i: directory_iterator(p)) { + if (is_regular_file(i.path())) { + LOG_GENERAL ("Inside there's regular file %1", i.path().string()); + add_path (i.path()); + } else if (is_directory(i.path()) && i.path().filename() != ".AppleDouble") { + LOG_GENERAL ("Inside there's directory %1", i.path().string()); + read_sub_directory (i.path()); + } else { + LOG_GENERAL("Ignoring %1 from inside: status is %2", i.path().string(), static_cast<int>(status(i.path()).type())); + } } + } catch (exception& e) { + LOG_GENERAL("Failed to iterate over %1: %2", p.string(), e.what()); } } |
