[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached ea76c7d660 2/7: Make sure update is used for s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached ea76c7d660 2/7: Make sure update is used for session validation |
Date: |
Mon, 21 Nov 2022 10:57:32 -0500 (EST) |
branch: externals/detached
commit ea76c7d6609aee2f305258395c1fa809edd28e53
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Make sure update is used for session validation
---
detached.el | 64 ++++++++++++++++++---------------------------------
test/detached-test.el | 1 -
2 files changed, 23 insertions(+), 42 deletions(-)
diff --git a/detached.el b/detached.el
index d0b57c9eff..b54edbb86c 100644
--- a/detached.el
+++ b/detached.el
@@ -347,8 +347,8 @@ This version is encoded as [package-version].[revision].")
(defvar detached--hashed-sessions nil
"Hashed sessions.")
-(defvar detached--unvalidated-sessions nil
- "List of unvalidated sessions.")
+(defvar detached--unvalidated-session-ids nil
+ "A list of unvalidated session ids.")
(defvar detached--current-emacsen nil
"List of current detached Emacsen.")
@@ -1184,8 +1184,8 @@ This function uses the `notifications' library."
(defun detached-session-validated-p (session)
"Return t if SESSION has been validated."
(not
- (alist-get (detached-session-id session)
- detached--unvalidated-sessions)))
+ (member (detached-session-id session)
+ detached--unvalidated-session-ids)))
(defun detached-session-failed-p (session)
"Return t if SESSION failed."
@@ -1376,19 +1376,18 @@ It can take some time for a dtach socket to be created.
Therefore all
sessions are created with state unknown. This function creates a
function to verify that a session was created correctly. If the
session is missing its deleted from the database."
- (setf (alist-get (detached--session-id session)
detached--unvalidated-sessions)
- session)
- (run-with-timer detached-dtach-socket-creation-delay
- nil
- (lambda ()
- (when (alist-get (detached-session-id session)
- detached--unvalidated-sessions)
- (setq detached--unvalidated-sessions
- (assq-delete-all (detached-session-id session)
- detached--unvalidated-sessions))
- (unless (detached--session-missing-p session)
- (setf (detached--session-state session) 'active)
- (detached--db-insert-entry session))))))
+ (let ((session-id (detached-session-id session)))
+ (push session-id detached--unvalidated-session-ids)
+ (run-with-timer detached-dtach-socket-creation-delay
+ nil
+ (lambda ()
+ (when (member session-id
detached--unvalidated-session-ids)
+ (setq detached--unvalidated-session-ids (delete
session-id detached--unvalidated-session-ids))
+ (let ((session (detached--db-get-session session-id)))
+ (if (detached--session-missing-p session)
+ (detached--db-remove-entry session)
+ (setf (detached--session-state session) 'active)
+ (detached--db-update-entry session))))))))
(defun detached--session-file (session file &optional local)
"Return the full path to SESSION's FILE.
@@ -1816,16 +1815,13 @@ session and trigger a state transition."
(string= "socket" (file-name-extension file)))
(when-let* ((id (intern (file-name-base file)))
- (session
- (or (alist-get id detached--unvalidated-sessions)
- (detached--db-get-session id)))
+ (session (detached--db-get-session id))
(session-directory (detached-session-directory session))
(is-primary
(detached--primary-detached-emacs-p session)))
;; Remove from unvalidated sessions
- (setq detached--unvalidated-sessions
- (assq-delete-all id detached--unvalidated-sessions))
+ (setq detached--unvalidated-session-ids (delete id
detached--unvalidated-session-ids))
;; Update session
(detached--session-state-transition-update session)
@@ -1847,17 +1843,12 @@ session and trigger a state transition."
(when (and (eq action 'created)
(string= "log" (file-name-extension file)))
(when-let* ((id (intern (file-name-base file)))
- (session
- (or (alist-get id detached--unvalidated-sessions)
- (detached--db-get-session id)))
+ (session (detached--db-get-session id))
(session-directory (detached-session-directory session))
- (is-primary
- (detached--primary-detached-emacs-p session)))
- (setq detached--unvalidated-sessions
- (assq-delete-all (detached-session-id session)
- detached--unvalidated-sessions))
+ (is-primary (detached--primary-detached-emacs-p session)))
+ (setq detached--unvalidated-session-ids (delete (detached-session-id
session) detached--unvalidated-session-ids))
(setf (detached--session-state session) 'active)
- (detached--db-insert-entry session)))))
+ (detached--db-update-entry session)))))
(defun detached--initialize-session (session)
"Initialize SESSION."
@@ -1874,16 +1865,7 @@ session and trigger a state transition."
(if (detached--state-transition-p session)
(detached--session-state-transition-update session 'approximate)
(detached--db-update-entry session)
- (detached--watch-session-directory (detached-session-directory
session)))
-
- ;; TODO(Niklas Eklund, 20221118): I should remove the autoremoval
- ;; code of the codebase, it prevents us from being able to create
- ;; a session without starting it.
-
- ;; (if (detached--session-missing-p session)
- ;; (detached--db-remove-entry session)
- ;; (detached--db-update-entry session))
- ))
+ (detached--watch-session-directory (detached-session-directory
session)))))
(defun detached--uninitialized-sessions ()
"Return a list of uninitialized sessions."
diff --git a/test/detached-test.el b/test/detached-test.el
index c3da87cad0..6f2ab10b27 100644
--- a/test/detached-test.el
+++ b/test/detached-test.el
@@ -49,7 +49,6 @@
((symbol-function #'emacs-pid) (lambda () 1))
(session (detached-create-session command)))
(detached-test--change-session-state session 'activate)
- (detached--db-insert-entry session)
session))
(defun detached-test--change-session-state (session state)
- [elpa] externals/detached updated (8c7a2e1129 -> 0c7586847f), ELPA Syncer, 2022/11/21
- [elpa] externals/detached 7c572dba30 1/7: Begin to enable delayed start of sessions, ELPA Syncer, 2022/11/21
- [elpa] externals/detached 7ed4551774 6/7: Fix detach in shell/eshell, ELPA Syncer, 2022/11/21
- [elpa] externals/detached ea76c7d660 2/7: Make sure update is used for session validation,
ELPA Syncer <=
- [elpa] externals/detached b59d39f68e 4/7: Add validation of dtach executable, ELPA Syncer, 2022/11/21
- [elpa] externals/detached 0c7586847f 7/7: Add kill command to detached-session-map, ELPA Syncer, 2022/11/21
- [elpa] externals/detached 68acc5429a 5/7: Update session actions for shell/eshell, ELPA Syncer, 2022/11/21
- [elpa] externals/detached 441c21f5da 3/7: Remove validator function, ELPA Syncer, 2022/11/21