changeset 225:c34794a7962b

arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 01 Sep 2008 18:47:59 +0200
parents bcd2ea17f130
children 9faa8f0e9f86
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Mon Sep 01 18:08:45 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Mon Sep 01 18:47:59 2008 +0200
@@ -38,10 +38,17 @@
     # only image needs to be rotated, webnail and thumbnail
     # will be recreated by the arnica parser
     image_object = Image.open(file_name)
+    # we save the old file (don't use .bak here)
+    tmp_file = file_name + '.tmp'
+    os.rename(file_name, tmp_file)
     try:
         image_object.rotate(angle).save(file_name, img_type)
     except IOError:
-        return
+        # in case of trouble rename to the old file
+        os.rename(tmp_name, file_name)
+    else:
+        # on success remove the backup file
+        os.unlink(tmp_file)
 
 def html_js(request, counter):
     """ javascript for the slides