[pitivi] medialibrary: Get the user thumbnails dir from GLib



commit b7e46dc95d6c67906fb46e06e77877d102bd8b85
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Oct 6 11:31:55 2016 +0200

    medialibrary: Get the user thumbnails dir from GLib
    
    get_user_cache_dir returns the proper dir, no need to check all three
    options anymore.
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D1358

 pitivi/medialibrary.py |   21 +++------------------
 1 files changed, 3 insertions(+), 18 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index c07f187..fa0865e 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -209,27 +209,12 @@ class AssetThumbnail(Loggable):
             if isinstance(stream_info, GstPbutils.DiscovererVideoInfo)]
         if video_streams:
             # Check if the files have thumbnails in the user's cache directory.
-            # https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DIRECTORY
             real_uri = get_proxy_target(self.__asset).props.id
             quoted_uri = quote_uri(real_uri)
             thumbnail_hash = md5(quoted_uri.encode()).hexdigest()
-            small_thumb, large_thumb = (None, None)
-            try:
-                thumb_dir = os.path.join(os.environ["XDG_CACHE_HOME"], "thumbnail")
-                small_thumb, large_thumb = self.__get_thumbnail_in_dir(
-                    thumb_dir, thumbnail_hash)
-            except KeyError:
-                pass
-            if not small_thumb:
-                thumb_dir = os.path.expanduser("~/.cache/thumbnails/")
-                small_thumb, large_thumb = self.__get_thumbnail_in_dir(
-                    thumb_dir, thumbnail_hash)
-            if not small_thumb:
-                # Older version of the spec also mentioned $HOME/.thumbnails
-                thumb_dir = os.path.expanduser("~/.thumbnails/")
-                small_thumb, large_thumb = self.__get_thumbnail_in_dir(
-                    thumb_dir, thumbnail_hash)
-
+            thumb_dir = os.path.join(GLib.get_user_cache_dir(), "thumbnail")
+            small_thumb, large_thumb = self.__get_thumbnail_in_dir(
+                thumb_dir, thumbnail_hash)
             if not small_thumb:
                 if self.__asset.is_image():
                     small_thumb, large_thumb = self.__get_icons("image-x-generic")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]