aboutsummaryrefslogtreecommitdiffhomepage
path: root/zipper.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'zipper.lisp')
-rw-r--r--zipper.lisp30
1 files changed, 26 insertions, 4 deletions
diff --git a/zipper.lisp b/zipper.lisp
index ede4a71..f83989f 100644
--- a/zipper.lisp
+++ b/zipper.lisp
@@ -2,9 +2,26 @@
(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."
- (ensure-directories-exist (merge-pathnames "media/bundled-playlists/" (static-directory *config*)))
(unless (zipped-playlist-exists-p playlist)
(let ((zip-file (zipped-playlist-path playlist)))
(with-temp-dir (tmpdir)
@@ -43,7 +60,12 @@
do (uiop:copy-file file dest)
collect dest))
-(defun delete-zipped-playlist (playlist)
+(defun make-zipped-playlist-link (playlist context)
+ (when (zipped-playlist-exists-p playlist)
+ (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."
- (princ "Deleting zipped playlist")
- (uiop:delete-file-if-exists (zipped-playlist-path playlist)))
+ (print "Deleting zipped playlist")
+ (uiop:delete-file-if-exists (zipped-playlist-path (playlist playlist-ctl)))
+ (destroy (pl-zip playlist-ctl)))