|
@@ -28,16 +28,15 @@
|
|
|
|
|
|
|
|
(defsetting *git-repos-root* "/tmp/ledger-repos/")
|
|
(defsetting *git-repos-root* "/tmp/ledger-repos/")
|
|
|
(defun git-get-chat-location (chat-id remote)
|
|
(defun git-get-chat-location (chat-id remote)
|
|
|
- (namestring (merge-pathnames (format nil "~A-~A" chat-id (token-hmac remote))
|
|
|
|
|
- *git-repos-root*)))
|
|
|
|
|
|
|
+ (namestring (uiop:ensure-directory-pathname
|
|
|
|
|
+ (merge-pathnames (format nil "~A-~A" chat-id (token-hmac remote))
|
|
|
|
|
+ *git-repos-root*))))
|
|
|
|
|
|
|
|
(defun git-read-latest-file (repo path)
|
|
(defun git-read-latest-file (repo path)
|
|
|
(bt:with-recursive-lock-held ((git-get-repo-lock repo))
|
|
(bt:with-recursive-lock-held ((git-get-repo-lock repo))
|
|
|
(legit:fetch repo :branch "master" :remote "origin")
|
|
(legit:fetch repo :branch "master" :remote "origin")
|
|
|
(legit:reset repo :hard t :to "origin/master")
|
|
(legit:reset repo :hard t :to "origin/master")
|
|
|
- (uiop:read-file-string (merge-pathnames path
|
|
|
|
|
- (uiop:ensure-directory-pathname
|
|
|
|
|
- (legit:location repo))))))
|
|
|
|
|
|
|
+ (uiop:read-file-string (merge-pathnames path (legit:location repo)))))
|
|
|
|
|
|
|
|
(defun ledger/refresh-git (chat-id remote path)
|
|
(defun ledger/refresh-git (chat-id remote path)
|
|
|
(let* ((location (git-get-chat-location chat-id remote))
|
|
(let* ((location (git-get-chat-location chat-id remote))
|
|
@@ -50,8 +49,7 @@
|
|
|
|
|
|
|
|
(defun git-append-latest-file (repo path text message)
|
|
(defun git-append-latest-file (repo path text message)
|
|
|
(bt:with-recursive-lock-held ((git-get-repo-lock repo))
|
|
(bt:with-recursive-lock-held ((git-get-repo-lock repo))
|
|
|
- (let ((repo-path (merge-pathnames path (uiop:ensure-directory-pathname
|
|
|
|
|
- (legit:location repo)))))
|
|
|
|
|
|
|
+ (let ((repo-path (merge-pathnames path (legit:location repo))))
|
|
|
(dotimes (tries 5)
|
|
(dotimes (tries 5)
|
|
|
(let ((current (or (ignore-errors (git-read-latest-file repo path)) "")))
|
|
(let ((current (or (ignore-errors (git-read-latest-file repo path)) "")))
|
|
|
(uiop/stream:with-output-file (s repo-path
|
|
(uiop/stream:with-output-file (s repo-path
|
|
@@ -187,6 +185,7 @@
|
|
|
(with-secret (info (list :ledger chat-id))
|
|
(with-secret (info (list :ledger chat-id))
|
|
|
(when info
|
|
(when info
|
|
|
(let ((chat-id (parse-integer chat-id)))
|
|
(let ((chat-id (parse-integer chat-id)))
|
|
|
|
|
+ (log:info "Updating ledger for ~A" chat-id)
|
|
|
(setf (gethash chat-id *ledger/chat-journals*) nil)
|
|
(setf (gethash chat-id *ledger/chat-journals*) nil)
|
|
|
(get-chat-journal-info chat-id info)
|
|
(get-chat-journal-info chat-id info)
|
|
|
"OK"))))))))
|
|
"OK"))))))))
|