Implemented with-files-write macro
- Bugfix: pin/ls didn't handle empty result correctly - Bugfix: Fixed edge case in simplify
This commit is contained in:
parent
d5e641c3ea
commit
fc5cc5a256
20
main.lisp
20
main.lisp
|
@ -46,7 +46,8 @@
|
||||||
(let* ((result (cond ((stringp body) body)
|
(let* ((result (cond ((stringp body) body)
|
||||||
((vectorp body) (flexi-streams:octets-to-string body))))
|
((vectorp body) (flexi-streams:octets-to-string body))))
|
||||||
(result (if (search "application/json" (cdr (assoc :content-type headers)))
|
(result (if (search "application/json" (cdr (assoc :content-type headers)))
|
||||||
(simplify (yason:parse result :object-as :alist))
|
(unless (empty-string-p result)
|
||||||
|
(simplify (yason:parse result :object-as :alist)))
|
||||||
result)))
|
result)))
|
||||||
(if (eql 200 status-code)
|
(if (eql 200 status-code)
|
||||||
result
|
result
|
||||||
|
@ -525,7 +526,17 @@ a local file.
|
||||||
:form-data t))))
|
:form-data t))))
|
||||||
(apply #'process-result result)))
|
(apply #'process-result result)))
|
||||||
|
|
||||||
|
(defmacro with-files-write ((stream dest-path &rest params) &body body)
|
||||||
|
"A convenience macro for files-write. In the body of the macro, any writes
|
||||||
|
to the stream named by STREAM will be sent to the mfs file at DEST-PATH. PARAMS
|
||||||
|
will be passed directly to the files-write function."
|
||||||
|
(let ((fn (gensym "FN")))
|
||||||
|
;;FIXME: Would be nice to write the stream directly to files-write.
|
||||||
|
;; This feels a little less efficient.
|
||||||
|
`(uiop:with-temporary-file (:stream ,stream :pathname ,fn)
|
||||||
|
,@body
|
||||||
|
:close-stream
|
||||||
|
(files-write ,fn ,dest-path ,@params))))
|
||||||
|
|
||||||
;; —————————————————————————————————————
|
;; —————————————————————————————————————
|
||||||
;; FILESTORE CALLS
|
;; FILESTORE CALLS
|
||||||
|
@ -783,7 +794,8 @@ a local file.
|
||||||
(defun pin-ls (&key (path nil) (type "all"))
|
(defun pin-ls (&key (path nil) (type "all"))
|
||||||
"List objects pinned to local storage.
|
"List objects pinned to local storage.
|
||||||
/ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-ls"
|
/ipns/docs.ipfs.io/reference/api/http/#api-v0-pin-ls"
|
||||||
(ipfs-call "pin/ls" `(,(when path `("arg" ,path)) ("type" ,type))))
|
(let ((res (ipfs-call "pin/ls" `(,(when path `("arg" ,path)) ("type" ,type)))))
|
||||||
|
(if (equal res '("Keys")) nil res)))
|
||||||
|
|
||||||
;; STRING [:BOOLEAN] → ALIAS || (NIL STRING)
|
;; STRING [:BOOLEAN] → ALIAS || (NIL STRING)
|
||||||
(defun pin-rm (path &key (recursive 'T))
|
(defun pin-rm (path &key (recursive 'T))
|
||||||
|
@ -1059,7 +1071,7 @@ a local file.
|
||||||
(stringp (cdr list)))
|
(stringp (cdr list)))
|
||||||
(cdr list))
|
(cdr list))
|
||||||
((and (eq 1 (length list))
|
((and (eq 1 (length list))
|
||||||
(consp list))
|
(consp (car list)))
|
||||||
(simplify (car list)))
|
(simplify (car list)))
|
||||||
((and (consp list)
|
((and (consp list)
|
||||||
(stringp (car list))
|
(stringp (car list))
|
||||||
|
|
|
@ -168,4 +168,5 @@
|
||||||
|
|
||||||
;; version calls
|
;; version calls
|
||||||
:version
|
:version
|
||||||
:version-deps))
|
:version-deps
|
||||||
|
#:with-files-write))
|
||||||
|
|
Ŝarĝante…
Reference in New Issue