[bknr-cvs] hans changed trunk/bknr/web/src/images/image.lisp

BKNR Commits bknr at bknr.net
Fri Dec 5 09:49:45 UTC 2008


Revision: 4113
Author: hans
URL: http://bknr.net/trac/changeset/4113

Add new :IF-EXISTS keyword argument to MAKE-STORE-IMAGE that can be
set to control whether an existing image of the same name should be
overwritten.

U   trunk/bknr/web/src/images/image.lisp

Modified: trunk/bknr/web/src/images/image.lisp
===================================================================
--- trunk/bknr/web/src/images/image.lisp	2008-12-04 15:02:57 UTC (rev 4112)
+++ trunk/bknr/web/src/images/image.lisp	2008-12-05 09:49:44 UTC (rev 4113)
@@ -65,12 +65,20 @@
 			 name
 			 (type :png)
 			 directory keywords
+                         (if-exists :error)
 			 (class-name 'store-image)
 			 initargs)
   (unless (scan #?r"\D" name)
     (error "invalid image name ~A, needs to contain at least one non-digit character" name))
-  (when (store-image-with-name name)
-    (error "can't make image with name ~A, an image with this name already exists in the datastore" name))
+  (when-let (existing-image (store-image-with-name name))
+    (ecase if-exists
+      (:error
+       (error "can't make image with name ~A, an image with this name already exists in the datastore" name))
+      (:supersede
+       (delete-object existing-image))
+      (:kill
+       (delete-file (blob-pathname existing-image))
+       (delete-object existing-image))))
   (let ((store-image (apply #'make-instance
 			    class-name
 			    :name name





More information about the Bknr-cvs mailing list