aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-08-29 14:50:07 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-08-31 22:35:24 -0700
commit78aeec9bcea6bec274120bbd8824e251697a372e (patch)
treed8ca4e586a937d371282bf6e4cf235d8ae5682fb
parent23b3dc9d0323073792d5eb87760616be1debf728 (diff)
downloadconsfigurator-78aeec9bcea6bec274120bbd8824e251697a372e.tar.gz
:LOCAL CONNECTION-WRITEFILE: use UIOP:RENAME-FILE-OVERWRITING-TARGET
Avoids starting an external process. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/connection/local.lisp12
-rw-r--r--src/package.lisp2
2 files changed, 13 insertions, 1 deletions
diff --git a/src/connection/local.lisp b/src/connection/local.lisp
index 53bfc20..41944ff 100644
--- a/src/connection/local.lisp
+++ b/src/connection/local.lisp
@@ -68,7 +68,17 @@
:if-exists :supersede
:element-type type)
(copy-stream-to-stream content stream :element-type type)))))
- (run-program `("mv" ,temp ,path))))
+ ;; TEMP's pathname will always have a PATHNAME-TYPE which is the random
+ ;; string of characters suffixed to make the filename unique. If PATH
+ ;; doesn't have a file extension then the merging behaviour of RENAME-FILE
+ ;; will add the random suffix as the file type of the rename destination.
+ ;; So we make two new pathnames.
+ (flet ((detype-pathname (pn)
+ (make-pathname
+ :defaults uiop:*nil-pathname* :type :unspecific
+ :name (pathname-file pn) :directory (pathname-directory pn))))
+ (rename-file-overwriting-target
+ (detype-pathname temp) (detype-pathname path)))))
(defmethod connection-connattr
((connection local-connection) (k (eql :XDG-CACHE-HOME)))
diff --git a/src/package.lisp b/src/package.lisp
index 2aaa1f3..7b526ea 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -32,6 +32,7 @@
#:directory-files
#:file-exists-p
#:directory-exists-p
+ #:rename-file-overwriting-target
#:with-current-directory
#:delete-empty-directory
#:delete-directory-tree
@@ -70,6 +71,7 @@
#:directory-files
#:file-exists-p
#:directory-exists-p
+ #:rename-file-overwriting-target
#:with-current-directory
#:delete-empty-directory
#:delete-directory-tree