Skip to content

Commit

Permalink
When reading a file or buffer, first make sure it exists to avoid thr…
Browse files Browse the repository at this point in the history
…owing an exception
  • Loading branch information
jayemar committed Sep 24, 2023
1 parent 81b791e commit 8f0c6fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- "**"

jobs:
test:
Expand Down
5 changes: 2 additions & 3 deletions obsidian.el
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ If you need to run this manually, please report this as an issue on Github."
"Return string contents of a file or current buffer.
If FILE is not specified, use the current buffer."
;; (if (and file (file-exists-p file))
(if file
(if (and file (file-exists-p file))
(with-temp-buffer
(insert-file-contents file)
(buffer-substring-no-properties (point-min) (point-max)))
Expand Down Expand Up @@ -504,7 +503,7 @@ If the file include directories in its path, we create the file relative to
(s-concat obsidian-directory "/"
obsidian-inbox-directory "/" f)))
(cleaned (s-replace "//" "/" filename)))
(if (not (file-exists-p cleaned))
(if (not (f-exists-p cleaned))
(progn
(f-mkdir-full-path (f-dirname cleaned))
(f-touch cleaned)
Expand Down

0 comments on commit 8f0c6fc

Please sign in to comment.