summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-07-04 12:43:46 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-07-04 12:43:46 +0200
commit35495fba60be1f1684c7b055e350eeaef092c2cb (patch)
treedf4acb77e8facf6bddf53d897be5db2c55e391c8
parent84107bdd772255e735584b330d8521f52513ac28 (diff)
downloadpoezio-35495fba60be1f1684c7b055e350eeaef092c2cb.tar.gz
poezio-35495fba60be1f1684c7b055e350eeaef092c2cb.tar.bz2
poezio-35495fba60be1f1684c7b055e350eeaef092c2cb.tar.xz
poezio-35495fba60be1f1684c7b055e350eeaef092c2cb.zip
a
-rw-r--r--poezio/xhtml.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/poezio/xhtml.py b/poezio/xhtml.py
index 68bbe095..09fa782f 100644
--- a/poezio/xhtml.py
+++ b/poezio/xhtml.py
@@ -307,7 +307,7 @@ class XHTMLHandler(sax.ContentHandler):
# do not care about xhtml-in namespace
self.force_ns = force_ns
- self.tmp_image_dir = tmp_image_dir
+ self.tmp_image_dir = Path(tmp_image_dir) if tmp_image_dir else None
self.enable_css_parsing = config.get('enable_css_parsing')
@property
@@ -361,9 +361,10 @@ class XHTMLHandler(sax.ContentHandler):
]
bin_data = b64decode(unquote(data))
filename = get_hash(bin_data) + '.' + type_
- filepath = path.join(self.tmp_image_dir, filename)
+ filepath = self.tmp_image_dir / filename
if not path.exists(filepath):
try:
+ self.tmp_image_dir.mkdir(parents=True, exist_ok=True)
with open(filepath, 'wb') as fd:
fd.write(bin_data)
builder.append('[file stored as %s]' % filename)