merge with dev

This commit is contained in:
Desmis
2017-07-06 18:10:25 +02:00
21 changed files with 366 additions and 317 deletions

View File

@@ -32,7 +32,7 @@
#include "options.h"
#include "procparamchangers.h"
#include "thumbnail.h"
#include "md5helper.h"
//#include "md5helper.h"
namespace
{
@@ -308,10 +308,42 @@ void CacheManager::deleteFiles (const Glib::ustring& fname, const std::string& m
error |= g_remove (getCacheFileName ("mip", fname, ".mip", md5).c_str ());
}
}
if (error != 0 && options.rtSettings.verbose) {
std::cerr << "Failed to delete all files for cache entry '" << fname << "': " << g_strerror (errno) << std::endl;
std::string CacheManager::getMD5 (const Glib::ustring& fname)
{
#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);
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
{
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);
}
} catch(Gio::Error&) {}
}
#endif
return {};
}
Glib::ustring CacheManager::getCacheFileName (const Glib::ustring& subDir,