Skip to content

Commit e69a79a

Browse files
committed
Create magithub-dir if it doesn't already exist
1 parent 5e44374 commit e69a79a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

magithub-cache.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ context. If t, `magithub-source-repo' is used."
185185
(if (active-minibuffer-window)
186186
(run-with-idle-timer 10 nil #'magithub-cache-write-to-disk) ;defer
187187
(when magithub-cache--needs-write
188-
(with-temp-buffer
189-
(insert (prin1-to-string magithub-cache--cache))
190-
(write-file magithub-cache-file))
188+
(magithub-in-data-dir
189+
(with-temp-buffer
190+
(insert (prin1-to-string magithub-cache--cache))
191+
(write-file magithub-cache-file)))
191192
(setq magithub-cache--needs-write nil)
192193
(magithub-debug-message "wrote cache to disk"))))
193194

magithub-core.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ Respects `magithub-debug-mode' and `debug-on-error'."
4949
(expand-file-name "magithub" user-emacs-directory)
5050
"Data directory.")
5151

52+
(defmacro magithub-in-data-dir (&rest forms)
53+
"Execute forms in `magithub-dir'.
54+
If `magithub-dir' does not yet exist, it and its parents will be
55+
created automatically."
56+
`(progn
57+
(unless (file-directory-p magithub-dir)
58+
(mkdir magithub-dir t))
59+
(let ((default-directory magithub-dir))
60+
,@forms)))
61+
5262
(defun magithub-github-repository-p ()
5363
"Non-nil if \"origin\" points to GitHub or a whitelisted domain."
5464
(when-let ((origin (magit-get "remote" "origin" "url")))

0 commit comments

Comments
 (0)