aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.lisp1
-rw-r--r--zipper.lisp17
2 files changed, 12 insertions, 6 deletions
diff --git a/package.lisp b/package.lisp
index ded3da3..c24492c 100644
--- a/package.lisp
+++ b/package.lisp
@@ -2,6 +2,7 @@
(defpackage #:vampire
(:use #:cl #:clog)
+ (:local-nicknames (#:zippy #:org.shirakumo.zippy ))
(:import-from #:bknr.datastore
#:with-transaction
#:store-object
diff --git a/zipper.lisp b/zipper.lisp
index 8ed37aa..91fafba 100644
--- a/zipper.lisp
+++ b/zipper.lisp
@@ -6,10 +6,12 @@
"Compresses playlist tracks into a zip archive."
(unless (zipped-playlist-exists-p playlist)
(let ((zip-file (zipped-playlist-path playlist)))
+ (ensure-directories-exist zip-file)
(with-temp-dir (tmpdir)
- (with-open-file (_foo zip-file :if-does-not-exist :create :direction :output :if-exists :overwrite)
- (org.shirakumo.zippy:compress-zip
- (copy-audio-files-for-download playlist tmpdir) zip-file :if-exists :overwrite))))))
+ (copy-audio-files-for-download playlist tmpdir)
+ (zippy:compress-zip
+ tmpdir zip-file :if-exists :supersede)))))
+
(defun zip-track-filename (track pos)
"Return a filename for a track. `NN-ARTIST-ALBUM-TITLE.CODEC'"
@@ -22,16 +24,19 @@
(defun zipped-playlist-path (playlist)
"Returns the zipped playlist path relative to the configured static directory."
- (merge-pathnames (pathname-utils:to-relative (zipped-playlist-url playlist))
+ (merge-pathnames (zipped-playlist-url playlist :absolute nil)
(static-directory *config*)))
-(defun zipped-playlist-url (playlist)
+(defun zipped-playlist-url (playlist &key (absolute t))
"Returns the url where the playlist's zip file is expected to exist."
- (merge-pathnames (zipped-playlist-filename playlist) "/media/bundled-playlists/"))
+ (format nil "~:[~;/~]media/bundled-playlists/~a"
+ absolute
+ (zipped-playlist-filename playlist)))
(defun zipped-playlist-exists-p (playlist)
(uiop:file-exists-p (zipped-playlist-path playlist)))
+
(defun copy-audio-files-for-download (playlist dir)
"Copies all playlist tracks into a temporary directory and returns a list of the pathnames."
(loop for track in (playlist-tracks playlist)