From 6de599379a58012d3d334d431cf852337f88c0bd Mon Sep 17 00:00:00 2001 From: Nicolas Bernard Date: Mon, 14 Dec 2020 09:30:43 +0100 Subject: [PATCH] Handle org-roam-server-db-last-modification as a float to avoid integer 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 --- org-roam-server.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/org-roam-server.el b/org-roam-server.el index bbcfd15..d383516 100644 --- a/org-roam-server.el +++ b/org-roam-server.el @@ -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." @@ -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)