diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-29 14:50:07 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-08-31 22:35:24 -0700 |
commit | 78aeec9bcea6bec274120bbd8824e251697a372e (patch) | |
tree | d8ca4e586a937d371282bf6e4cf235d8ae5682fb /src/connection/local.lisp | |
parent | 23b3dc9d0323073792d5eb87760616be1debf728 (diff) | |
download | consfigurator-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>
Diffstat (limited to 'src/connection/local.lisp')
-rw-r--r-- | src/connection/local.lisp | 12 |
1 files changed, 11 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))) |