Browse Source

add keyword args to get-storage-file and write rename-storage-file.

These changes are in the nera package. I, also, got Emacs to auto
format the file -- that is why is are loads of line changes in the diff.
stable
Craig Oates 2 years ago
parent
commit
f3d856f7f4
  1. 19
      src/nera.lisp

19
src/nera.lisp

@ -33,7 +33,8 @@
#:system-data
#:add-storage-file
#:get-storage-file
#:get-all-storage-files))
#:get-all-storage-files
#:rename-storage-file))
(in-package #:nera-db)
(defparameter *tables* '(user site-settings page storage-file)
@ -241,13 +242,25 @@
:slug slug
:file-type file-type)))
(defun get-storage-file (filename)
(defun get-storage-file (&key filename slug)
"Returns a `STORAGE-FILE' row from the database. `NIL' if nothing found."
(with-connection (db)
(mito:find-dao 'storage-file :name filename)))
(if (null slug)
(mito:find-dao 'files:storage-file :name filename)
(mito:find-dao 'files:storage-file :slug slug))))
(defun get-all-storage-files ()
"Returns a list of all `STORAGE-FILES' entries in the database."
(with-connection (db)
(mito:select-dao 'storage-file
(sxql:order-by (:asc :name)))))
(defun rename-storage-file (old-file-name new-file-name)
"Renames `STORAGE-FILE' in the database.
The `NAME' is renamed from `OLD-FILE-NAME' to `NEW-FILE-NAME' and the
slug is updated based on `NEW-FILE-NAME'."
(with-connection (db)
(let ((file-to-rename (mito:find-dao 'storage-file :name old-file-name)))
(setf (files::name-of file-to-rename) new-file-name
(files::slug-of file-to-rename) (utils:slugify new-file-name))
(mito:save-dao file-to-rename))))

Loading…
Cancel
Save