summaryrefslogtreecommitdiff
path: root/comparison.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:22:18 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:22:18 +0200
commitbcc5cc28c6dc5178e8f4fd0cc521034ae5def388 (patch)
treebacc60d27b435d32172f97643576c5e4e953177d /comparison.cpp
parent5.9 (diff)
downloadFreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.tar.gz
FreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.tar.bz2
FreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.zip
5.10
Diffstat (limited to 'comparison.cpp')
-rw-r--r--comparison.cpp89
1 files changed, 79 insertions, 10 deletions
diff --git a/comparison.cpp b/comparison.cpp
index bae14c41..3e99e366 100644
--- a/comparison.cpp
+++ b/comparison.cpp
@@ -82,19 +82,88 @@ void determineExistentDirs(const std::set<Zstring, LessFilename>& dirnames,
bool allowUserInteraction,
ProcessCallback& callback)
{
- std::for_each(dirnames.begin(), dirnames.end(),
- [&](const Zstring& dirname)
+ std::vector<Zstring> dirs(dirnames.begin(), dirnames.end());
+ vector_remove_if(dirs, [](const Zstring& dir) { return dir.empty(); });
+
+
+
+ warn_static("finish")
+ /*
+ //check existence of all directories in parallel! (avoid adding up search times if multiple network drives are not reachable)
+ FixedList<boost::unique_future<bool>> asyncDirChecks;
+ std::for_each(dirs.begin(), dirs.end(), [&](const Zstring& dirname)
{
- if (!dirname.empty())
- {
- if (tryReportingError([&]
+ asyncDirChecks.emplace_back(async([=]() -> bool
+ {
+ #ifdef FFS_WIN
+ //1. login to network share, if necessary
+ loginNetworkShare(dirname, allowUserInteraction);
+ #endif
+ //2. check dir existence
+ return zen::dirExists(dirname);
+ }));
+ });
+
+ auto timeMax = boost::get_system_time() + boost::posix_time::seconds(10); //limit total directory search time
+
+ auto iterCheckDir = asyncDirChecks.begin();
+ for (auto iter = dirs.begin(); iter != dirs.end(); ++iter, ++iterCheckDir)
+ {
+ const Zstring& dirname = *iter;
+ callback.reportStatus(replaceCpy(_("Searching for folder %x..."), L"%x", fmtFileName(dirname), false));
+
+ while (boost::get_system_time() < timeMax && !iterCheckDir->timed_wait(boost::posix_time::milliseconds(UI_UPDATE_INTERVAL)))
+ callback.requestUiRefresh(); //may throw!
+
+ //only (still) existing files should be included in the list
+ if (iterCheckDir->is_ready() && iterCheckDir->get())
+ dirnamesExisting.insert(dirname);
+ else
+ {
+
+ switch (callback.reportError(replaceCpy(_("Cannot find folder %x."), L"%x", fmtFileName(dirname)) + L"\n\n" +
+ _("You can ignore this error to consider the folder as empty."))) //may throw!
{
- if (!dirExistsUpdating(dirname, allowUserInteraction, callback))
- throw FileError(replaceCpy(_("Cannot find folder %x."), L"%x", fmtFileName(dirname)) + L"\n\n" +
- _("You can ignore this error to consider the folder as empty."));
- }, callback))
- dirnamesExisting.insert(dirname);
+ case ProcessCallback::IGNORE_ERROR:
+ break;
+ case ProcessCallback::RETRY:
+ break; //continue with loop
}
+
+
+ if (tryReportingError([&]
+ {
+ if (!dirExistsUpdating(dirname, allowUserInteraction, callback))
+ throw FileError();
+
+
+
+
+ }, callback))
+ dirnamesExisting.insert(dirname);
+ }
+ }
+ */
+
+
+
+
+
+
+
+
+
+
+ std::for_each(dirs.begin(), dirs.end(),
+ [&](const Zstring& dirname)
+ {
+ if (tryReportingError([&]
+ {
+ if (!dirExistsUpdating(dirname, allowUserInteraction, callback))
+ throw FileError(replaceCpy(_("Cannot find folder %x."), L"%x", fmtFileName(dirname)) + L"\n\n" +
+ _("You can ignore this error to consider the folder as empty."));
+ }, callback))
+ dirnamesExisting.insert(dirname);
});
}
bgstack15