mirror of https://codeberg.org/cage/tinmop/
- [kami] made an effort to replicate the permissions when uploading a file.
This commit is contained in:
parent
f46fb4dc14
commit
560e01e09e
|
@ -314,6 +314,11 @@
|
||||||
|
|
||||||
(define-stat-time atime)
|
(define-stat-time atime)
|
||||||
|
|
||||||
|
(defun get-stat-mode (file)
|
||||||
|
(let ((raw (nix:stat-mode (nix:stat file))))
|
||||||
|
(values raw
|
||||||
|
(logand raw #o777))))
|
||||||
|
|
||||||
(defun file-hash (file)
|
(defun file-hash (file)
|
||||||
(num:fnv-hash-32 (slurp-file file :convert-to-string nil)))
|
(num:fnv-hash-32 (slurp-file file :convert-to-string nil)))
|
||||||
|
|
||||||
|
|
|
@ -118,24 +118,26 @@
|
||||||
(lambda (source-path destination-path)
|
(lambda (source-path destination-path)
|
||||||
(let* ((*stream* stream)
|
(let* ((*stream* stream)
|
||||||
(*root-fid* root-fid))
|
(*root-fid* root-fid))
|
||||||
(with-open-file (input-stream source-path
|
(let ((source-permissions (fs:get-stat-mode source-path)))
|
||||||
:direction :input
|
(with-open-file (input-stream source-path
|
||||||
:element-type +octect-type+)
|
:direction :input
|
||||||
(with-cloned-root-fid (*stream* root-fid)
|
:element-type +octect-type+)
|
||||||
(9p:remove-path *stream* root-fid destination-path))
|
(with-cloned-root-fid (*stream* root-fid)
|
||||||
(with-cloned-root-fid (*stream* root-fid)
|
(9p:remove-path *stream* root-fid destination-path))
|
||||||
(let* ((buffer (misc:make-array-frame +download-buffer+ 0 +octect-type+ t))
|
(with-cloned-root-fid (*stream* root-fid)
|
||||||
(fid (9p:create-path *stream* root-fid destination-path)))
|
(let* ((buffer (misc:make-array-frame +download-buffer+ 0 +octect-type+ t))
|
||||||
(loop named write-loop
|
(fid (9p:create-path *stream* root-fid destination-path)))
|
||||||
for read-so-far = (read-sequence buffer input-stream)
|
(loop named write-loop
|
||||||
then (read-sequence buffer input-stream)
|
for read-so-far = (read-sequence buffer input-stream)
|
||||||
for offset = 0 then (+ offset read-so-far)
|
then (read-sequence buffer input-stream)
|
||||||
do
|
for offset = 0 then (+ offset read-so-far)
|
||||||
(9p:9p-write *stream* fid offset (subseq buffer 0 read-so-far))
|
do
|
||||||
(when (< read-so-far +download-buffer+)
|
(9p:9p-write *stream* fid offset (subseq buffer 0 read-so-far))
|
||||||
(return-from write-loop t)))
|
(when (< read-so-far +download-buffer+)
|
||||||
(9p:9p-clunk *stream* fid)
|
(return-from write-loop t)))
|
||||||
(9p:read-all-pending-messages stream)))))))
|
(9p:9p-clunk *stream* fid)
|
||||||
|
(9p:change-mode *stream* *root-fid* destination-path source-permissions)
|
||||||
|
(9p:read-all-pending-messages stream))))))))
|
||||||
|
|
||||||
(defun query-path (stream root-fid)
|
(defun query-path (stream root-fid)
|
||||||
(lambda (path what)
|
(lambda (path what)
|
||||||
|
|
|
@ -306,6 +306,7 @@
|
||||||
:get-stat-mtime
|
:get-stat-mtime
|
||||||
:get-stat-ctime
|
:get-stat-ctime
|
||||||
:get-stat-atime
|
:get-stat-atime
|
||||||
|
:get-stat-mode
|
||||||
:file-outdated-p
|
:file-outdated-p
|
||||||
:file-exists-p
|
:file-exists-p
|
||||||
:directory-exists-p
|
:directory-exists-p
|
||||||
|
|
Loading…
Reference in New Issue