From 5a0e69961fdd9f764c2cd8784d1362c6025b83b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Thu, 26 Dec 2019 21:54:17 +0100
Subject: [PATCH] [preview] Rename directory vars

---
 url_image_preview/url_image_preview.py | 20 +++++++++-----------
 url_image_preview/utils.py             |  4 ++--
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/url_image_preview/url_image_preview.py b/url_image_preview/url_image_preview.py
index a8d4e0d1..6e66fe78 100644
--- a/url_image_preview/url_image_preview.py
+++ b/url_image_preview/url_image_preview.py
@@ -116,16 +116,14 @@ class UrlImagePreviewPlugin(GajimPlugin):
         self._session.props.https_aliases = ['aesgcm']
         self._session.props.ssl_strict = False
 
-        self.directory = os.path.join(configpaths.get('MY_DATA'),
-                                      'downloads')
-        self.thumbpath = os.path.join(configpaths.get('MY_CACHE'),
-                                      'downloads.thumb')
+        self._orig_dir = Path(configpaths.get('MY_DATA')) / 'downloads'
+        self._thumb_dir = Path(configpaths.get('MY_CACHE')) / 'downloads.thumb'
 
-        if GLib.mkdir_with_parents(self.directory, 0o700) != 0:
-            log.error('Failed to create: %s', self.directory)
+        if GLib.mkdir_with_parents(str(self._orig_dir), 0o700) != 0:
+            log.error('Failed to create: %s', self._orig_dir)
 
-        if GLib.mkdir_with_parents(self.thumbpath, 0o700) != 0:
-            log.error('Failed to create: %s', self.directory)
+        if GLib.mkdir_with_parents(str(self._thumb_dir), 0o700) != 0:
+            log.error('Failed to create: %s', self._thumb_dir)
 
         self._migrate_config()
 
@@ -156,7 +154,7 @@ class UrlImagePreviewPlugin(GajimPlugin):
 
         if len(text.split(' ')) > 1:
             # urlparse doesn't recognise spaces as URL delimiter
-            log.debug('Text is not an uri: %s', text[:15])
+            log.debug('Text is not an uri: %s...', text[:15])
             return
 
         uri = text
@@ -272,8 +270,8 @@ class UrlImagePreviewPlugin(GajimPlugin):
         orig_path, thumb_path = get_image_paths(uri,
                                                 urlparts,
                                                 size,
-                                                self.directory,
-                                                self.thumbpath)
+                                                self._orig_dir,
+                                                self._thumb_dir)
         return Preview(uri,
                        urlparts,
                        orig_path,
diff --git a/url_image_preview/utils.py b/url_image_preview/utils.py
index fe92c360..830bb6ec 100644
--- a/url_image_preview/utils.py
+++ b/url_image_preview/utils.py
@@ -299,8 +299,8 @@ def get_image_paths(uri, urlparts, size, orig_dir, thumb_dir):
                                            size,
                                            extension)
 
-    orig_path = Path(orig_dir) / orig_filename
-    thumb_path = Path(thumb_dir) / thumb_filename
+    orig_path = orig_dir / orig_filename
+    thumb_path = thumb_dir / thumb_filename
     return orig_path, thumb_path
 
 
-- 
GitLab