Small speedup for file browser
This commit is contained in:
@@ -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<wchar_t, GFreeFunc> wfname (reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free);
|
||||
std::unique_ptr<wchar_t, GFreeFunc> wfname(reinterpret_cast<wchar_t*>(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 {};
|
||||
}
|
||||
|
||||
|
@@ -1792,38 +1792,36 @@ void FileCatalog::on_dir_changed (const Glib::RefPtr<Gio::File>& file, const Gli
|
||||
|
||||
void FileCatalog::checkAndAddFile (Glib::RefPtr<Gio::File> 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&) {}
|
||||
|
Reference in New Issue
Block a user