[niepce] Make the thumbnail name unique based on its id.
- From: Hubert FiguiÃre <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Make the thumbnail name unique based on its id.
- Date: Sat, 12 Nov 2011 06:17:25 +0000 (UTC)
commit 7b4b8460de7a4f1cefe36a3be81f5564c2cf4ef8
Author: Hub Figuiere <hub figuiere net>
Date: Tue Nov 8 08:22:04 2011 -0800
Make the thumbnail name unique based on its id.
src/engine/library/thumbnailcache.cpp | 12 +++++++-----
src/engine/library/thumbnailcache.hpp | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/engine/library/thumbnailcache.cpp b/src/engine/library/thumbnailcache.cpp
index 10e4d90..7143fae 100644
--- a/src/engine/library/thumbnailcache.cpp
+++ b/src/engine/library/thumbnailcache.cpp
@@ -23,6 +23,7 @@
#include <boost/bind.hpp>
#include <boost/any.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/format.hpp>
#include <gdkmm/pixbuf.h>
#include <libopenraw-gnome/gdkpixbuf.h>
@@ -139,7 +140,7 @@ void ThumbnailCache::execute(const ThumbnailTask::Ptr & task)
Glib::RefPtr<Gdk::Pixbuf> pix;
- std::string dest = path_for_thumbnail(task->file()->path(), std::max(w,h));
+ std::string dest = path_for_thumbnail(task->file()->path(), task->file()->id(), std::max(w,h));
DBG_OUT("cached thumbnail %s", dest.c_str());
pix = getThumbnail(task->file(), w, h, dest);
@@ -161,16 +162,17 @@ void ThumbnailCache::execute(const ThumbnailTask::Ptr & task)
}
}
-std::string ThumbnailCache::path_for_thumbnail(const std::string & filename, int size) const
+std::string ThumbnailCache::path_for_thumbnail(const std::string & filename, library_id_t id, int size) const
{
- // todo compute a hash
- return dir_for_thumbnail(size) + fwk::path_basename(filename) + ".png";
+ // todo compute a better hash
+ std::string thumb_name = str(boost::format("%1%-%2%.png") % id % fwk::path_basename(filename));
+ return Glib::build_filename(dir_for_thumbnail(size), thumb_name);
}
std::string ThumbnailCache::dir_for_thumbnail(int size) const
{
std::string subdir = size ? boost::lexical_cast<std::string>(size) : "full";
- return m_cacheDir + "/" + subdir + "/";
+ return Glib::build_filename(m_cacheDir, subdir);
}
bool ThumbnailCache::is_thumbnail_cached(const std::string & /*file*/, const std::string & thumb)
diff --git a/src/engine/library/thumbnailcache.hpp b/src/engine/library/thumbnailcache.hpp
index 90cb273..de3b9eb 100644
--- a/src/engine/library/thumbnailcache.hpp
+++ b/src/engine/library/thumbnailcache.hpp
@@ -71,7 +71,7 @@ private:
std::string m_cacheDir;
std::tr1::weak_ptr<fwk::NotificationCenter> m_notif_center;
- std::string path_for_thumbnail(const std::string & filename, int size) const;
+ std::string path_for_thumbnail(const std::string & filename, library_id_t id, int size) const;
std::string dir_for_thumbnail(int size) const;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]