summaryrefslogtreecommitdiff
path: root/zipper.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'zipper.lisp')
-rw-r--r--zipper.lisp32
1 files changed, 7 insertions, 25 deletions
diff --git a/zipper.lisp b/zipper.lisp
index f83989f..0271159 100644
--- a/zipper.lisp
+++ b/zipper.lisp
@@ -2,24 +2,6 @@
(in-package :vampire)
-(defvar *zip-cluster*)
-
-(defun start-zipper-service (config)
- (let ((zipped-dir (merge-pathnames "media/bundled-playlists/" (static-directory config))))
- (ensure-directories-exist zipped-dir)
- (setf *zip-cluster* (legion:make-cluster (downloader-threads config)
- (lambda (job) (funcall job)))))
- (legion:start *zip-cluster*))
-
-(defun add-zip-playlist-job (playlist ok err)
- "PLAYLIST is a PLAYLIST instance. OK ... ERR ..."
- (legion:add-job
- *zip-cluster*
- (lambda ()
- (handler-case
- (funcall ok (zip-playlist playlist))
- (error (e) (funcall err e))))))
-
(defun zip-playlist (playlist)
"Compresses playlist tracks into a zip archive."
(unless (zipped-playlist-exists-p playlist)
@@ -32,12 +14,11 @@
(defun zip-track-filename (track pos)
"Return a filename for a track. `NN-ARTIST-ALBUM-TITLE.CODEC'"
(with-slots (artist album title codec) track
- (format nil "~2,'0d-~a-~a-~a.~a" pos
- (clean-slashes artist) (clean-slashes album) (clean-slashes title) codec)))
+ (clean-filename (format nil "~2,'0d-~a-~a-~a.~a" pos artist album title codec))))
(defun zipped-playlist-filename (playlist)
"Return a url-safe zip filename for a playlist."
- (concatenate 'string (clean-slashes (playlist-title playlist)) ".zip"))
+ (concatenate 'string (clean-filename (playlist-title playlist)) ".zip"))
(defun zipped-playlist-path (playlist)
"Returns the zipped playlist path relative to the configured static directory."
@@ -65,7 +46,8 @@
(create-a context :link (zipped-playlist-url playlist) :content "Download" :target "_blank")))
(defun delete-zipped-playlist (playlist-ctl)
- "Deletes the zipped playlist file. Returns T if it was deleted, NIL otherwise."
- (print "Deleting zipped playlist")
- (uiop:delete-file-if-exists (zipped-playlist-path (playlist playlist-ctl)))
- (destroy (pl-zip playlist-ctl)))
+ "Deletes the zipped playlist file and removes the associated link element.
+Returns T if it was deleted, NIL otherwise."
+ (when (uiop:delete-file-if-exists (zipped-playlist-path (playlist playlist-ctl)))
+ (unless (null (pl-zip playlist-ctl))
+ (destroy (pl-zip playlist-ctl)))))