Refresh cached image data if sidecar is changed
This commit is contained in:
parent
572a75f02a
commit
c557b320c2
@ -26,6 +26,15 @@
|
|||||||
#include "../rtengine/procparams.h"
|
#include "../rtengine/procparams.h"
|
||||||
#include "../rtengine/settings.h"
|
#include "../rtengine/settings.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
const Glib::ustring INI_GROUP_XMP_SIDECAR = "XmpSidecar";
|
||||||
|
const Glib::ustring INI_XMP_SIDECAR_MD5 = "MD5";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CacheImageData::CacheImageData() :
|
CacheImageData::CacheImageData() :
|
||||||
supported(false),
|
supported(false),
|
||||||
format(FT_Invalid),
|
format(FT_Invalid),
|
||||||
@ -108,6 +117,12 @@ int CacheImageData::load (const Glib::ustring& fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyFile.has_group(INI_GROUP_XMP_SIDECAR)) {
|
||||||
|
if (keyFile.has_key(INI_GROUP_XMP_SIDECAR, INI_XMP_SIDECAR_MD5)) {
|
||||||
|
xmpSidecarMd5 = keyFile.get_string(INI_GROUP_XMP_SIDECAR, INI_XMP_SIDECAR_MD5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
timeValid = keyFile.has_group ("DateTime");
|
timeValid = keyFile.has_group ("DateTime");
|
||||||
|
|
||||||
if (timeValid) {
|
if (timeValid) {
|
||||||
@ -268,6 +283,8 @@ int CacheImageData::save (const Glib::ustring& fname)
|
|||||||
keyFile.set_boolean ("General", "RecentlySaved", recentlySaved);
|
keyFile.set_boolean ("General", "RecentlySaved", recentlySaved);
|
||||||
keyFile.set_integer ("General", "Rating", rating);
|
keyFile.set_integer ("General", "Rating", rating);
|
||||||
|
|
||||||
|
keyFile.set_string(INI_GROUP_XMP_SIDECAR, INI_XMP_SIDECAR_MD5, xmpSidecarMd5);
|
||||||
|
|
||||||
// remove the old implementation of Rank and InTrash from cache
|
// remove the old implementation of Rank and InTrash from cache
|
||||||
if (keyFile.has_key ("General", "Rank")) {
|
if (keyFile.has_key ("General", "Rank")) {
|
||||||
keyFile.remove_key("General", "Rank");
|
keyFile.remove_key("General", "Rank");
|
||||||
|
@ -39,6 +39,9 @@ public:
|
|||||||
bool inTrashOld; // old implementation of inTrash
|
bool inTrashOld; // old implementation of inTrash
|
||||||
bool recentlySaved;
|
bool recentlySaved;
|
||||||
|
|
||||||
|
// XMP sidecar info.
|
||||||
|
Glib::ustring xmpSidecarMd5;
|
||||||
|
|
||||||
// time/date info
|
// time/date info
|
||||||
bool timeValid;
|
bool timeValid;
|
||||||
short year;
|
short year;
|
||||||
|
@ -97,6 +97,10 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto cacheName = getCacheFileName ("data", fname, ".txt", md5);
|
const auto cacheName = getCacheFileName ("data", fname, ".txt", md5);
|
||||||
|
const auto xmpSidecarMd5 =
|
||||||
|
rtengine::settings->metadata_xmp_sync != rtengine::Settings::MetadataXmpSync::NONE
|
||||||
|
? getMD5(Thumbnail::xmpSidecarPath(fname))
|
||||||
|
: "";
|
||||||
|
|
||||||
// let's see if we have it in the cache
|
// let's see if we have it in the cache
|
||||||
{
|
{
|
||||||
@ -106,6 +110,11 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname)
|
|||||||
|
|
||||||
if (error == 0 && imageData.supported) {
|
if (error == 0 && imageData.supported) {
|
||||||
|
|
||||||
|
if (xmpSidecarMd5 != imageData.xmpSidecarMd5) {
|
||||||
|
updateImageInfo(fname, imageData, xmpSidecarMd5);
|
||||||
|
imageData.save(cacheName);
|
||||||
|
}
|
||||||
|
|
||||||
thumbnail.reset (new Thumbnail (this, fname, &imageData));
|
thumbnail.reset (new Thumbnail (this, fname, &imageData));
|
||||||
|
|
||||||
if (!thumbnail->isSupported ()) {
|
if (!thumbnail->isSupported ()) {
|
||||||
@ -117,7 +126,7 @@ Thumbnail* CacheManager::getEntry (const Glib::ustring& fname)
|
|||||||
// if not, create a new one
|
// if not, create a new one
|
||||||
if (!thumbnail) {
|
if (!thumbnail) {
|
||||||
|
|
||||||
thumbnail.reset (new Thumbnail (this, fname, md5));
|
thumbnail.reset (new Thumbnail (this, fname, md5, xmpSidecarMd5));
|
||||||
|
|
||||||
if (!thumbnail->isSupported ()) {
|
if (!thumbnail->isSupported ()) {
|
||||||
thumbnail.reset ();
|
thumbnail.reset ();
|
||||||
@ -413,3 +422,9 @@ void CacheManager::applyCacheSizeLimitation () const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CacheManager::updateImageInfo(const Glib::ustring &fname, CacheImageData &imageData, const Glib::ustring &xmpSidecarMd5) const
|
||||||
|
{
|
||||||
|
Thumbnail::infoFromImage(fname, imageData);
|
||||||
|
imageData.xmpSidecarMd5 = xmpSidecarMd5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "../rtengine/noncopyable.h"
|
#include "../rtengine/noncopyable.h"
|
||||||
|
|
||||||
|
class CacheImageData;
|
||||||
class Thumbnail;
|
class Thumbnail;
|
||||||
|
|
||||||
class CacheManager :
|
class CacheManager :
|
||||||
@ -42,6 +43,7 @@ private:
|
|||||||
void deleteFiles (const Glib::ustring& fname, const std::string& md5, bool purgeData, bool purgeProfile) const;
|
void deleteFiles (const Glib::ustring& fname, const std::string& md5, bool purgeData, bool purgeProfile) const;
|
||||||
|
|
||||||
void applyCacheSizeLimitation () const;
|
void applyCacheSizeLimitation () const;
|
||||||
|
void updateImageInfo(const Glib::ustring &fname, CacheImageData &imageData, const Glib::ustring &xmpSidecarMd5) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CacheManager* getInstance ();
|
static CacheManager* getInstance ();
|
||||||
|
@ -148,7 +148,7 @@ Thumbnail::Thumbnail(CacheManager* cm, const Glib::ustring& fname, CacheImageDat
|
|||||||
tpp = nullptr;
|
tpp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thumbnail::Thumbnail(CacheManager* cm, const Glib::ustring& fname, const std::string& md5) :
|
Thumbnail::Thumbnail(CacheManager* cm, const Glib::ustring& fname, const std::string& md5, const std::string &xmpSidecarMd5) :
|
||||||
fname(fname),
|
fname(fname),
|
||||||
cachemgr(cm),
|
cachemgr(cm),
|
||||||
ref(1),
|
ref(1),
|
||||||
@ -166,6 +166,7 @@ Thumbnail::Thumbnail(CacheManager* cm, const Glib::ustring& fname, const std::st
|
|||||||
|
|
||||||
|
|
||||||
cfs.md5 = md5;
|
cfs.md5 = md5;
|
||||||
|
cfs.xmpSidecarMd5 = xmpSidecarMd5;
|
||||||
loadProcParams ();
|
loadProcParams ();
|
||||||
_generateThumbnailImage ();
|
_generateThumbnailImage ();
|
||||||
cfs.recentlySaved = false;
|
cfs.recentlySaved = false;
|
||||||
@ -176,6 +177,11 @@ Thumbnail::Thumbnail(CacheManager* cm, const Glib::ustring& fname, const std::st
|
|||||||
tpp = nullptr;
|
tpp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::ustring Thumbnail::xmpSidecarPath(const Glib::ustring &imagePath)
|
||||||
|
{
|
||||||
|
return rtengine::Exiv2Metadata::xmpSidecarPath(imagePath);
|
||||||
|
}
|
||||||
|
|
||||||
void Thumbnail::_generateThumbnailImage ()
|
void Thumbnail::_generateThumbnailImage ()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -852,7 +858,12 @@ ThFileType Thumbnail::getType () const
|
|||||||
|
|
||||||
int Thumbnail::infoFromImage (const Glib::ustring& fname)
|
int Thumbnail::infoFromImage (const Glib::ustring& fname)
|
||||||
{
|
{
|
||||||
rtengine::FramesMetaData* idata = rtengine::FramesMetaData::fromFile (fname);
|
return infoFromImage(fname, cfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Thumbnail::infoFromImage(const Glib::ustring &fname, CacheImageData &cfs)
|
||||||
|
{
|
||||||
|
std::unique_ptr<rtengine::FramesMetaData> idata(rtengine::FramesMetaData::fromFile (fname));
|
||||||
|
|
||||||
if (!idata) {
|
if (!idata) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -915,7 +926,6 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname)
|
|||||||
|
|
||||||
idata->getDimensions(cfs.width, cfs.height);
|
idata->getDimensions(cfs.width, cfs.height);
|
||||||
|
|
||||||
delete idata;
|
|
||||||
return deg;
|
return deg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,12 @@ class Thumbnail
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf);
|
Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf);
|
||||||
Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5);
|
Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5, const std::string &xmpSidecarMd5);
|
||||||
~Thumbnail ();
|
~Thumbnail ();
|
||||||
|
|
||||||
|
static int infoFromImage(const Glib::ustring &fname, CacheImageData &cfs);
|
||||||
|
static Glib::ustring xmpSidecarPath(const Glib::ustring &imagePath);
|
||||||
|
|
||||||
bool hasProcParams () const;
|
bool hasProcParams () const;
|
||||||
const rtengine::procparams::ProcParams& getProcParams ();
|
const rtengine::procparams::ProcParams& getProcParams ();
|
||||||
const rtengine::procparams::ProcParams& getProcParamsU (); // Unprotected version
|
const rtengine::procparams::ProcParams& getProcParamsU (); // Unprotected version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user