projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixup! More debugging.
[dcpomatic.git]
/
src
/
lib
/
find_missing.cc
diff --git
a/src/lib/find_missing.cc
b/src/lib/find_missing.cc
index 3d61e74bd4f9b2b330f92ea7ba9c5e2bfc73293c..41d1416fcf0beaae9ddc43d53abf9c4f7e685176 100644
(file)
--- a/
src/lib/find_missing.cc
+++ b/
src/lib/find_missing.cc
@@
-20,6
+20,7
@@
#include "content.h"
#include "content.h"
+#include "dcpomatic_log.h"
#include "find_missing.h"
#include "util.h"
#include <boost/filesystem.hpp>
#include "find_missing.h"
#include "util.h"
#include <boost/filesystem.hpp>
@@
-37,19
+38,31
@@
static
void
search (Replacements& replacement_paths, boost::filesystem::path directory, int depth = 0)
{
void
search (Replacements& replacement_paths, boost::filesystem::path directory, int depth = 0)
{
- for (auto candidate: boost::filesystem::directory_iterator(directory)) {
+ boost::system::error_code ec;
+ for (auto candidate: boost::filesystem::directory_iterator(directory, ec)) {
+ LOG_GENERAL("Have candidate %1", candidate.path().string());
if (boost::filesystem::is_regular_file(candidate.path())) {
for (auto& replacement: replacement_paths) {
for (auto& path: replacement.second) {
if (!boost::filesystem::exists(path) && path.filename() == candidate.path().filename()) {
if (boost::filesystem::is_regular_file(candidate.path())) {
for (auto& replacement: replacement_paths) {
for (auto& path: replacement.second) {
if (!boost::filesystem::exists(path) && path.filename() == candidate.path().filename()) {
+ LOG_GENERAL("Accept %1", candidate.path());
path = candidate.path();
path = candidate.path();
+ } else {
+ LOG_GENERAL("Reject %1", candidate.path());
}
}
}
} else if (boost::filesystem::is_directory(candidate.path()) && depth <= 2) {
}
}
}
} else if (boost::filesystem::is_directory(candidate.path()) && depth <= 2) {
+ LOG_GENERAL("Recurse into %1", candidate.path().string());
search (replacement_paths, candidate, depth + 1);
search (replacement_paths, candidate, depth + 1);
+ } else {
+ LOG_GENERAL("Candidate was ignored; depth=%1", candidate.path().string());
}
}
}
}
+
+ /* Just ignore errors when creating the directory_iterator; they can be triggered by things like
+ * macOS' love of creating random directories (see #2291).
+ */
}
}
@@
-58,6
+71,14
@@
dcpomatic::find_missing (vector<shared_ptr<Content>> content_to_fix, boost::file
{
using namespace boost::filesystem;
{
using namespace boost::filesystem;
+ LOG_GENERAL_NC("Find missing to fix:");
+ for (auto content: content_to_fix) {
+ for (auto file: content->paths()) {
+ LOG_GENERAL(" %1", file.string());
+ }
+ }
+ LOG_GENERAL("Clue is %1", clue);
+
Replacements replacement_paths;
for (auto content: content_to_fix) {
replacement_paths[content] = content->paths();
Replacements replacement_paths;
for (auto content: content_to_fix) {
replacement_paths[content] = content->paths();
@@
-68,7
+89,13
@@
dcpomatic::find_missing (vector<shared_ptr<Content>> content_to_fix, boost::file
for (auto content: content_to_fix) {
auto const& repl = replacement_paths[content];
bool const replacements_exist = std::find_if(repl.begin(), repl.end(), [](path p) { return !exists(p); }) == repl.end();
for (auto content: content_to_fix) {
auto const& repl = replacement_paths[content];
bool const replacements_exist = std::find_if(repl.begin(), repl.end(), [](path p) { return !exists(p); }) == repl.end();
+ LOG_GENERAL("replacements_exist? %1", replacements_exist ? "yes" : "no");
+ LOG_GENERAL("digest match? %1", simple_digest(replacement_paths[content]) == content->digest() ? "yes" : "no");
if (replacements_exist && simple_digest(replacement_paths[content]) == content->digest()) {
if (replacements_exist && simple_digest(replacement_paths[content]) == content->digest()) {
+ LOG_GENERAL_NC("Setting content paths:");
+ for (auto const& i: repl) {
+ LOG_GENERAL(" %1", i);
+ }
content->set_paths (repl);
}
}
content->set_paths (repl);
}
}