Don't save unmodified code
This commit is contained in:
parent
1bc6ec544d
commit
1e12d5d3e2
@ -809,6 +809,15 @@
|
|||||||
(uri-path
|
(uri-path
|
||||||
(request-uri request))))
|
(request-uri request))))
|
||||||
|
|
||||||
|
;; Snippet dir path relative to stor-base
|
||||||
|
(ref-stor-dir
|
||||||
|
(let ((ref (assoc 'referer (request-headers request))))
|
||||||
|
(and ref
|
||||||
|
(let ((p (get-storage-dir (cdr ref) root)))
|
||||||
|
(and (storage-dir-valid? p)
|
||||||
|
(storage-path-exists? (path+ stor-base p))
|
||||||
|
p)))))
|
||||||
|
|
||||||
;; Body of the POST request
|
;; Body of the POST request
|
||||||
(code
|
(code
|
||||||
(if request-body
|
(if request-body
|
||||||
@ -828,6 +837,10 @@
|
|||||||
|
|
||||||
(logger LOG-VERBOSE "Request ~a:~a" (request-method request) path)
|
(logger LOG-VERBOSE "Request ~a:~a" (request-method request) path)
|
||||||
(logger LOG-VERBOSE "Request query:~a" query)
|
(logger LOG-VERBOSE "Request query:~a" query)
|
||||||
|
(logger LOG-DBG " stor:'~a' len:~a/~a"
|
||||||
|
ref-stor-dir
|
||||||
|
(request-content-length request)
|
||||||
|
(string-length code))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
;;
|
;;
|
||||||
@ -909,6 +922,17 @@
|
|||||||
;; Save snippet
|
;; Save snippet
|
||||||
((or (equal? path savecode-path))
|
((or (equal? path savecode-path))
|
||||||
(logger LOG-DBG "Request code saving")
|
(logger LOG-DBG "Request code saving")
|
||||||
|
(let ((old-code
|
||||||
|
(if ref-stor-dir
|
||||||
|
(read-from-storage (path+ stor-base ref-stor-dir))
|
||||||
|
DEFAULT-CODE)))
|
||||||
|
(if (equal? code old-code)
|
||||||
|
;; If code is not changed do nothing
|
||||||
|
(make-response
|
||||||
|
(encode-and-join-uri-path
|
||||||
|
(append root-path `(,ref-stor-dir)))
|
||||||
|
#:content-type 'text/plain)
|
||||||
|
;; New code save to new location
|
||||||
(let ((stor-dir
|
(let ((stor-dir
|
||||||
(basename
|
(basename
|
||||||
(mkdtemp
|
(mkdtemp
|
||||||
@ -921,7 +945,7 @@
|
|||||||
(make-response
|
(make-response
|
||||||
(encode-and-join-uri-path
|
(encode-and-join-uri-path
|
||||||
(append root-path `(,stor-dir)))
|
(append root-path `(,stor-dir)))
|
||||||
#:content-type 'text/plain)))
|
#:content-type 'text/plain)))))
|
||||||
|
|
||||||
;; Wrong POST request
|
;; Wrong POST request
|
||||||
(else
|
(else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user