Ver código fonte

[ledger] fix git paths once more

Innocenty Enikeew 8 anos atrás
pai
commit
397e5b2d5f
1 arquivos alterados com 6 adições e 7 exclusões
  1. 6 7
      plugins/ledger.lisp

+ 6 - 7
plugins/ledger.lisp

@@ -28,16 +28,15 @@
 
 (defsetting *git-repos-root* "/tmp/ledger-repos/")
 (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)
   (bt:with-recursive-lock-held ((git-get-repo-lock repo))
     (legit:fetch repo :branch "master" :remote "origin")
     (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)
   (let* ((location (git-get-chat-location chat-id remote))
@@ -50,8 +49,7 @@
 
 (defun git-append-latest-file (repo path text message)
   (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)
         (let ((current (or (ignore-errors (git-read-latest-file repo path)) "")))
           (uiop/stream:with-output-file (s repo-path
@@ -187,6 +185,7 @@
           (with-secret (info (list :ledger chat-id))
             (when info
               (let ((chat-id (parse-integer chat-id)))
+                (log:info "Updating ledger for ~A" chat-id)
                 (setf (gethash chat-id *ledger/chat-journals*) nil)
                 (get-chat-journal-info chat-id info)
                 "OK"))))))))