Skip to content

Commit

Permalink
Handle org-roam-server-db-last-modification as a float to avoid integ…
Browse files Browse the repository at this point in the history
…er overflows.

On some architectures (e.g. armv7l), the use of 'floor' was raising an exception as the float-time value was too large to be converted into an integer.
Emacs actually only guarantees 28 bits for an integer [0].
This modification bypasses this issue by handling the org-roam-server-db-last-modification as a float.

[0] https://ftp.gnu.org/old-gnu/Manuals/elisp-manual-21-2.8/html_node/elisp_58.html
  • Loading branch information
Nicolas Bernard committed Dec 14, 2020
1 parent 93b6732 commit 6de5993
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions org-roam-server.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"."))

(defvar org-roam-server-db-last-modification
(floor (float-time
(file-attribute-modification-time
(file-attributes org-roam-db-location)))))
(float-time
(file-attribute-modification-time
(file-attributes org-roam-db-location))))

(defgroup org-roam-server nil
"org-roam-server customizable variables."
Expand Down Expand Up @@ -526,15 +526,16 @@ DESCRIPTION is the shown attribute to the user if the image is not rendered."
(insert (format "data: %s\n\n"
(org-roam-server-visjs-json node-query)))
(when (and org-roam-server-network-poll
(not (eq org-roam-server-db-last-modification
(floor (float-time
(file-attribute-modification-time
(file-attributes org-roam-db-location)))))))
(> (abs (- org-roam-server-db-last-modification
(float-time
(file-attribute-modification-time
(file-attributes org-roam-db-location)))))
1e-6))
(let ((data (org-roam-server-visjs-json node-query)))
(setq org-roam-server-db-last-modification
(floor (float-time
(float-time
(file-attribute-modification-time
(file-attributes org-roam-db-location)))))
(file-attributes org-roam-db-location))))
(insert (format "data: %s\n\n" data)))))))

(defservlet* network-vis-options application/json (token)
Expand Down

0 comments on commit 6de5993

Please sign in to comment.