Created
May 21, 2012 18:29
-
-
Save alaa-alawi/2763794 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun make-upload-filename () | |
(etypecase *upload-filename-generator* | |
;; the old behaviour. | |
(null t) | |
;; the new behaviour. | |
((or symbol function) | |
(lambda (&rest args) | |
(let ((filename (apply *upload-filename-generator* args))) | |
(when *file-upload-hook* | |
(funcall *file-upload-hook* filename)) | |
filename))) | |
(directory-pathname | |
(lambda (&rest args &key file-name) | |
(let ((filename (make-pathname :name file-name | |
:directory *upload-filename-generator*))) | |
(when *file-upload-hook* | |
(funcall *file-upload-hook* filename)) | |
filename))))) | |
(deftype directory-pathname () | |
'(and pathname (satisfies cl-fad:directory-pathname-p))) |
Author
alaa-alawi
commented
May 28, 2012
This looks good - One more thing - The file-upload-hook invocation should be moved out of make-tmp-file-name and called from the function that is returned from make-upload-filename-generator, something like;
(let ((make-filename (ecase ...)))
(lambda (&rest args)
(let ((filename (funcall make-filename args)))
(when file-upload-hook
(funcall ..))
filename)))
i.e. don't spread the hacky file-upload-hook throughout the code if it can be localized to one place.
Thanks,
Hans
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment