Skip to content

Commit 245dae7

Browse files
committed
make storage dir, rm header detect for curl
1 parent 75bd1bb commit 245dae7

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

org-todoist.el

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@ this directory must be accessible on all PCs running the sync command."
372372
org-todoist--api-version-prop)))
373373
(unless (or (null vers) (string-blank-p vers))
374374
(intern vers)))
375-
;; No API version found, check for v9
376-
(when (org-todoist--is-v9 AST)
377-
'sync-v9)))
378-
;; no todoist file or version found
379-
org-todoist--default-api-version)))
375+
;; No API version found, check for v9
376+
(when (org-todoist--is-v9 AST)
377+
'sync-v9)))
378+
;; no todoist file or version found
379+
org-todoist--default-api-version)))
380380

381381
;Hooks;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
382382
(defun org-todoist--item-close-hook ()
@@ -543,9 +543,8 @@ the Todoist project, section, and optionally parent task."
543543

544544
(defun org-todoist--storage-file (FILE)
545545
"Determine full path of `FILE' relative to the `org-todoist-storage-dir'."
546-
(let ((path (expand-file-name FILE org-todoist-storage-dir)))
547-
(make-directory (file-name-directory path) t)
548-
path))
546+
(make-directory org-todoist-storage-dir t)
547+
(expand-file-name FILE org-todoist-storage-dir))
549548

550549
(defun org-todoist--set-sync-token (TOKEN)
551550
"Store that last Todoist sync `TOKEN'."
@@ -664,14 +663,9 @@ the Todoist project, section, and optionally parent task."
664663
(lambda (process event)
665664
(when (memq (process-status process) '(exit signal))
666665
(with-current-buffer (process-buffer process)
667-
(let ((exit-code (process-exit-status process))
668-
(headers-end (save-excursion
669-
(goto-char (point-min))
670-
(search-forward "\r\n\r\n" nil t)))) ; Find end of headers
666+
(let ((exit-code (process-exit-status process)))
671667
(if (= exit-code 0)
672-
(let* ((resp-body (if headers-end
673-
(buffer-substring-no-properties headers-end (point-max))
674-
(buffer-string)))
668+
(let* ((resp-body (buffer-string))
675669
(response (json-read-from-string resp-body)))
676670
(org-todoist--set-last-response resp-body)
677671
(apply callback-fn (cons response callback-args)))
@@ -743,6 +737,8 @@ Uses `curl' if available, otherwise falls back to `url-retrieve'."
743737
`OPEN' determines whether the Todoist buffer should be opened after sync."
744738
(when (or (null org-todoist-api-token) (not (stringp org-todoist-api-token)))
745739
(user-error "No org-todoist-api-token API token set"))
740+
(unless (org-todoist--is-current-api)
741+
(user-error "Org todoist has updated API versions! Run 'org-todoist-migrate-to-v1' to continue using org-todoist"))
746742
(setq org-todoist--sync-err nil)
747743
(let* ((cur-marker (point-marker))
748744
(ast (org-todoist--file-ast))
@@ -2891,7 +2887,7 @@ With prefix `ARG', include unassigned tasks.
28912887
(org-todoist-my-id USER))
28922888
(org-todoist-my-tasks current-prefix-arg USER)))
28932889

2894-
;;;###autoload
2890+
;;;###autoload
28952891
(defun org-todoist-ediff-snapshot ()
28962892
"Compare current org-todoist file with last synced snapshot using ediff."
28972893
(interactive)

0 commit comments

Comments
 (0)