From 78298c08ee3e612ae43b949b206a38ccd98c2fdf Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 22 Oct 2022 19:48:49 +0100 Subject: [PATCH] add remove-file-with-raw-path function in storage package. This function is part of the 'reset website' feature implemention. You should only need to call this when you want to delete something outsite of the /storage directory (I.E. the website's database). --- src/storage.lisp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/storage.lisp b/src/storage.lisp index 8d661ba..980d08a 100644 --- a/src/storage.lisp +++ b/src/storage.lisp @@ -20,7 +20,8 @@ #:store-with-raw-path #:store-text-with-raw-path #:open-text-file-with-raw-path - #:store-test)) + #:store-test + #:remove-file-with-raw-path)) (in-package #:storage) (defun init-storage () @@ -42,10 +43,11 @@ This is used as part of the /run-set defroute in web.lisp file." (uiop:copy-file (make-path "" "default-assets" "favicon.png") (merge-pathnames "static/images/favicon.png" ritherdon-archive.config:*application-root*)) - (ensure-directory-exists "" "snippets") (uiop:copy-file (make-path "" "default-assets" "site-wide-snippet.html") - (make-path "" "snippets" "site-wide-snippet.html"))) + (make-path "" "snippets" "site-wide-snippet.html")) + ;; Nothing is added to /storage/media yet, this is just prep. work. + (ensure-directory-exists "" "media")) (defun directory-exists-p (username directory) "Checks to see if the specified diretory exists. @@ -228,6 +230,13 @@ Use when reading text outside the /storage directory." (read-sequence data stream) data)))) + +(defun remove-file-with-raw-path (file-path) + "Deletes the specified file, at `PATH', use this to delete file outsite of /storage. +Before calling this function, make sure the file exists. You should have +'file-exists-p' available to you -- within this (storage) package." + (delete-file (merge-pathnames file-path ritherdon-archive.config::*application-root*))) + ;;; PORTED FROM RAILS-TO-CAVEMAN PROJECT (expect it to be deleted) ;;; =============================================================================