[web/views] unlink svg temp file after we're done
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 14 Dec 2015 12:11:44 +0100
changeset 10970 894c14f08380
parent 10955 2fe19ba68daa
child 10971 de59a60a9e40
[web/views] unlink svg temp file after we're done Otherwise we fill up the tempdir. Closes #9133268.
web/views/schema.py
--- a/web/views/schema.py	Wed Dec 09 16:36:17 2015 +0100
+++ b/web/views/schema.py	Mon Dec 14 12:11:44 2015 +0100
@@ -657,10 +657,13 @@
                                               }))
         # svg image file
         fd, tmpfile = tempfile.mkstemp('.svg')
-        os.close(fd)
-        generator.generate(visitor, prophdlr, tmpfile)
-        with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile:
-            self.w(svgfile.read())
+        try:
+            os.close(fd)
+            generator.generate(visitor, prophdlr, tmpfile)
+            with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile:
+                self.w(svgfile.read())
+        finally:
+            os.unlink(tmpfile)
 
 # breadcrumbs ##################################################################