From 602c2d42c416ba7fcb7ea810403077974db48de4 Mon Sep 17 00:00:00 2001 From: natureh 510 Date: Sun, 3 Mar 2013 14:30:30 +0100 Subject: [PATCH] Solving issue 1730: "Long startup time / all files on all mounts are scanned while opening". The ICC profile's directory scanning is no more recursive. --- rtengine/iccstore.cc | 58 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index d32b04825..b5ceb2e81 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -218,42 +218,46 @@ void ICCStore::loadICCs(Glib::ustring rootDirName, bool nameUpper, std::mapbegin(); i!=dir->end(); ++i) { - Glib::ustring fname = dirname + *i; - Glib::ustring sname = *i; - // ignore directories - if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) { - size_t lastdot = sname.find_last_of ('.'); - if (lastdot!=Glib::ustring::npos && lastdot<=sname.size()-4 && (!sname.casefold().compare (lastdot, 4, ".icm") || !sname.casefold().compare (lastdot, 4, ".icc"))) { - Glib::ustring name = nameUpper ? sname.substr(0,lastdot).uppercase() : sname.substr(0,lastdot); - ProfileContent pc (fname); - if (pc.data) { - cmsHPROFILE profile = pc.toProfile (); - if (profile) { - resultProfiles[name] = profile; - resultProfileContents[name] = pc; + Glib::Dir* dir = NULL; + try { + if (!safe_file_test (dirname, Glib::FILE_TEST_IS_DIR)) return; + dir = new Glib::Dir (dirname); + } + catch (Glib::Exception& fe) { + return; + } + dirname = dirname + "/"; + for (Glib::DirIterator i = dir->begin(); i!=dir->end(); ++i) { + Glib::ustring fname = dirname + *i; + Glib::ustring sname = *i; + // ignore directories + if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) { + size_t lastdot = sname.find_last_of ('.'); + if (lastdot!=Glib::ustring::npos && lastdot<=sname.size()-4 && (!sname.casefold().compare (lastdot, 4, ".icm") || !sname.casefold().compare (lastdot, 4, ".icc"))) { + Glib::ustring name = nameUpper ? sname.substr(0,lastdot).uppercase() : sname.substr(0,lastdot); + ProfileContent pc (fname); + if (pc.data) { + cmsHPROFILE profile = pc.toProfile (); + if (profile) { + resultProfiles[name] = profile; + resultProfileContents[name] = pc; + } } } } - } else qDirs.push_front(fname); // for later scanning + // Removed recursive scanning, see issue #1730. + // To revert to the recursive method, just uncomment the next line. + + //else qDirs.push_front(fname); // for later scanning + } + delete dir; } - delete dir; } } -} // Determine the first monitor default profile of operating system, if selected void ICCStore::findDefaultMonitorProfile() {