diff --git a/rtgui/cachemanager.cc b/rtgui/cachemanager.cc index 3f5ea9582..d3d41ab3d 100644 --- a/rtgui/cachemanager.cc +++ b/rtgui/cachemanager.cc @@ -297,38 +297,36 @@ void CacheManager::deleteFiles (const Glib::ustring& fname, const std::string& m std::string CacheManager::getMD5 (const Glib::ustring& fname) { - auto file = Gio::File::create_for_path (fname); - - if (file && file->query_exists ()) { - #ifdef WIN32 - std::unique_ptr wfname (reinterpret_cast(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free); + std::unique_ptr wfname(reinterpret_cast(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free); - WIN32_FILE_ATTRIBUTE_DATA fileAttr; - if (GetFileAttributesExW (wfname.get (), GetFileExInfoStandard, &fileAttr)) { - // We use name, size and creation time to identify a file. - const auto identifier = Glib::ustring::compose ("%1-%2-%3-%4", fileAttr.nFileSizeLow, fileAttr.ftCreationTime.dwHighDateTime, fileAttr.ftCreationTime.dwLowDateTime, fname); - return Glib::Checksum::compute_checksum (Glib::Checksum::CHECKSUM_MD5, identifier); - } + WIN32_FILE_ATTRIBUTE_DATA fileAttr; + if (GetFileAttributesExW(wfname.get(), GetFileExInfoStandard, &fileAttr)) { + // We use name, size and creation time to identify a file. + const auto identifier = Glib::ustring::compose("%1-%2-%3-%4", fileAttr.nFileSizeLow, fileAttr.ftCreationTime.dwHighDateTime, fileAttr.ftCreationTime.dwLowDateTime, fname); + return Glib::Checksum::compute_checksum(Glib::Checksum::CHECKSUM_MD5, identifier); + } #else + const auto file = Gio::File::create_for_path(fname); + if (file) { + try { - - if (auto info = file->query_info ()) { + const auto info = file->query_info("standard::*") + if (info) { // We only use name and size to identify a file. - const auto identifier = Glib::ustring::compose ("%1%2", fname, info->get_size ()); - return Glib::Checksum::compute_checksum (Glib::Checksum::CHECKSUM_MD5, identifier); + const auto identifier = Glib::ustring::compose("%1%2", fname, info->get_size()); + return Glib::Checksum::compute_checksum(Glib::Checksum::CHECKSUM_MD5, identifier); } } catch(Gio::Error&) {} + } #endif - } - return {}; } diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 0d10ba125..fba3f432a 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -1792,38 +1792,36 @@ void FileCatalog::on_dir_changed (const Glib::RefPtr& file, const Gli void FileCatalog::checkAndAddFile (Glib::RefPtr file) { - if (!file) { - return; - } - if (!file->query_exists()) { + if (!file) { return; } try { - auto info = file->query_info (); + const auto info = file->query_info("standard::*"); - if (!info || info->get_file_type () == Gio::FILE_TYPE_DIRECTORY) { + if (!info || info->get_file_type() == Gio::FILE_TYPE_DIRECTORY) { return; } - if (!options.fbShowHidden && info->is_hidden ()) { + if (!options.fbShowHidden && info->is_hidden()) { return; } Glib::ustring ext; - const auto lastdot = info->get_name ().find_last_of ('.'); + const auto lastdot = info->get_name().find_last_of('.'); + if (lastdot != Glib::ustring::npos) { - ext = info->get_name ().substr (lastdot + 1); + ext = info->get_name().substr(lastdot + 1); } - if (!options.is_extention_enabled (ext)) { + if (!options.is_extention_enabled(ext)) { return; } - previewLoader->add (selectedDirectoryId, file->get_parse_name (), this); + previewLoader->add(selectedDirectoryId, file->get_parse_name(), this); previewsToLoad++; } catch(Gio::Error&) {}