[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures i
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures in configuration |
Date: |
Wed, 19 Jan 2022 18:57:42 -0500 (EST) |
branch: externals/dtache
commit 2a38a9b538554029121dbe0bcce97499679c29ac
Author: Niklas Eklund <niklas.eklund@zenseact.com>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Robustify against failures in configuration
Make sure dtache doesn't fail if user configures dtache-dtach-program
or dtache-env incorrectly.
---
dtache.el | 96 ++++++++++++++++++++++++++++++---------------------------------
1 file changed, 46 insertions(+), 50 deletions(-)
diff --git a/dtache.el b/dtache.el
index c982d0d553..c0fa2efdd2 100644
--- a/dtache.el
+++ b/dtache.el
@@ -341,14 +341,16 @@ Sessions running on current host or localhost are
updated."
(let ((current-host (dtache--host))
(updated-sessions))
(setq updated-sessions
- (seq-map (lambda (it)
- (if (and (or (string= current-host (dtache--session-host
it))
- (string= "localhost" (dtache--session-host
it)))
- (or (dtache--session-active it)
- (dtache--session-deactivated-p it)))
- (dtache-update-session it)
- it))
- dtache--sessions))
+ (thread-last
+ dtache--sessions
+ (seq-map (lambda (it)
+ (if (and (or (string= current-host
(dtache--session-host it))
+ (string= "localhost" (dtache--session-host
it)))
+ (or (dtache--session-active it)
+ (dtache--session-deactivated-p it)))
+ (dtache-update-session it)
+ it)))
+ (seq-remove #'null)))
(dtache--db-update-sessions updated-sessions)))
(defun dtache-session-file (session file)
@@ -375,21 +377,13 @@ Sessions running on current host or localhost are
updated."
(defun dtache-update-session (session)
"Update SESSION."
- (when (dtache--session-deactivated-p session)
- (progn
- (setf (dtache--session-active session) nil)
- (setf (dtache--session-duration session)
- (dtache--duration session))
- (if-let ((status (dtache--session-status-function session)))
- (setf (dtache--session-status session) (funcall status session))
- (setf (dtache--session-status session)
(dtache-session-exit-code-status session)))
- (dtache-session-finish-notification session)
- (when-let ((callback (dtache--session-callback-function session)))
- (funcall callback session))))
- (setf (dtache--session-output-size session)
- (file-attribute-size (file-attributes
- (dtache-session-file session 'log))))
- session)
+ (if (or (dtache--session-deactivated-p session)
+ (dtache--session-missing-p session))
+ (dtache--session-final-update session)
+ (setf (dtache--session-output-size session)
+ (file-attribute-size (file-attributes
+ (dtache-session-file session 'log))))
+ session))
(defun dtache-initialize ()
"Initialize `dtache'."
@@ -410,7 +404,8 @@ Sessions running on current host or localhost are updated."
(if (and (string= "localhost"
(dtache--session-host it))
(dtache--session-active it))
(dtache-update-session it)
- it)))))
+ it)))
+ (seq-remove #'null)))
;; Setup notifications
(thread-last dtache--sessions
@@ -632,14 +627,6 @@ Sessions running on current host or localhost are
updated."
"..."
(substring command (- (length command) (/ part-length 2)) (length
command))))))
-(defun dtache--session-update (session)
- "Update the `dtache' SESSION."
- (setf (dtache--session-active session) (dtache--session-active-p session))
- (setf (dtache--session-output-size session) (file-attribute-size
- (file-attributes
- (dtache-session-file session
'log))))
- session)
-
(defun dtache--session-short-id (session)
"Return the short representation of the SESSION's id."
(let ((id (dtache--session-id session)))
@@ -741,29 +728,38 @@ Sessions running on current host or localhost are
updated."
(lambda (event)
(pcase-let ((`(,_ ,action ,_) event))
(when (eq action 'deleted)
- ;; Update session
- (setf (dtache--session-output-size session) (file-attribute-size
- (file-attributes
- (dtache-session-file
session 'log))))
+ (dtache--session-final-update session))))))
+
+(defun dtache--session-final-update (session)
+ "Make a final update to SESSION."
+ (if (dtache--session-missing-p session)
+ ;; Remove missing session
+ nil
+
+ ;; Update session
+ (setf (dtache--session-output-size session)
+ (file-attribute-size
+ (file-attributes
+ (dtache-session-file session 'log))))
- (setf (dtache--session-active session) nil)
- (setf (dtache--session-duration session)
- (- (time-to-seconds) (dtache--session-creation-time session)))
+ (setf (dtache--session-active session) nil)
+ (setf (dtache--session-duration session)
+ (- (time-to-seconds) (dtache--session-creation-time session)))
- ;; Update session in database
- (dtache--db-update-session session)
+ ;; Update session in database
+ (dtache--db-update-session session)
- ;; Update status
- (if-let ((status (dtache--session-status-function session)))
- (setf (dtache--session-status session) (funcall status session))
- (setf (dtache--session-status session)
(dtache-session-exit-code-status session)))
+ ;; Update status
+ (if-let ((status (dtache--session-status-function session)))
+ (setf (dtache--session-status session) (funcall status session))
+ (setf (dtache--session-status session) (dtache-session-exit-code-status
session)))
- ;; Send notification
- (dtache-session-finish-notification session)
+ ;; Send notification
+ (dtache-session-finish-notification session)
- ;; Execute callback
- (when-let ((callback (dtache--session-callback-function session)))
- (funcall callback session)))))))
+ ;; Execute callback
+ (when-let ((callback (dtache--session-callback-function session)))
+ (funcall callback session))))
(defun dtache--eat-cookie (&rest _)
"Eat the disambiguation cookie in the minibuffer."
- [elpa] externals/dtache 082139f1c3 045/158: Add instructions on how to customize annotations, (continued)
- [elpa] externals/dtache 082139f1c3 045/158: Add instructions on how to customize annotations, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache f6c9710c1b 017/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 99fd5c5b5c 025/158: Make sure to erase the output buffer, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b2eabec6c7 041/158: Improve dtache actions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 357432877c 033/158: Implement annotation/affixation function, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache ecc7563302 048/158: Update LICENSE, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2958d21869 035/158: Remove marginalia from dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache afb2684f38 027/158: Improve dtache-env command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c29079e0c0 047/158: Remove dtache-session-history, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache db230154e4 016/158: Merge develop branch into master, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 2a38a9b538 030/158: Robustify against failures in configuration,
ELPA Syncer <=
- [elpa] externals/dtache 115de6c1a2 022/158: Add default value for dtache-max-command-length, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 09d378e50a 024/158: Fix read-only problematic, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 4e99fc9daa 049/158: Deprecate dtache-list-sessions, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache cb1762ffc2 052/158: Add presentation about dtache version 0.2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5d9c8aa54f 053/158: Add macOS support, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 01a27b4dc2 056/158: Update README with reference to consult-dtache, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b75af1b9a7 059/158: Update notification setup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache b47bc3be09 061/158: Update copyright years, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 182ab7ccc6 064/158: Add integration with consult, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache ea6d8ae426 068/158: Add missing autoloads, ELPA Syncer, 2022/01/19