mirror of https://github.com/djcb/mu.git
mu4e: automatically rebuild database when possible
This commit is contained in:
parent
8f24b4103a
commit
26dca831c6
|
@ -253,13 +253,14 @@ Start the process if needed."
|
||||||
(unless (file-executable-p mu4e-mu-binary)
|
(unless (file-executable-p mu4e-mu-binary)
|
||||||
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
|
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
|
||||||
(let* ((process-connection-type nil) ;; use a pipe
|
(let* ((process-connection-type nil) ;; use a pipe
|
||||||
(args '("server"))
|
(args '("server"))
|
||||||
(args (append args (when mu4e-mu-home
|
(args (append args (when mu4e-mu-home (list (concat "--muhome=" mu4e-mu-home)))))
|
||||||
(list (concat "--muhome=" mu4e-mu-home))))))
|
(args (append args (list (concat "--maildir=" mu4e-maildir)))))
|
||||||
(setq mu4e~proc-buf "")
|
(setq mu4e~proc-buf "")
|
||||||
|
(message "%S" args)
|
||||||
(setq mu4e~proc-process (apply 'start-process
|
(setq mu4e~proc-process (apply 'start-process
|
||||||
mu4e~proc-name mu4e~proc-name
|
mu4e~proc-name mu4e~proc-name
|
||||||
mu4e-mu-binary args))
|
mu4e-mu-binary args))
|
||||||
;; register a function for (:info ...) sexps
|
;; register a function for (:info ...) sexps
|
||||||
(unless mu4e~proc-process
|
(unless mu4e~proc-process
|
||||||
(mu4e-error "Failed to start the mu4e backend"))
|
(mu4e-error "Failed to start the mu4e backend"))
|
||||||
|
@ -293,23 +294,19 @@ Start the process if needed."
|
||||||
(setq mu4e~proc-buf "") ;; clear any half-received sexps
|
(setq mu4e~proc-buf "") ;; clear any half-received sexps
|
||||||
(cond
|
(cond
|
||||||
((eq status 'signal)
|
((eq status 'signal)
|
||||||
(cond
|
(cond
|
||||||
((or(eq code 9) (eq code 2)) (message nil))
|
((or(eq code 9) (eq code 2)) (message nil))
|
||||||
;;(message "the mu server process has been stopped"))
|
;;(message "the mu server process has been stopped"))
|
||||||
(t (error (format "mu server process received signal %d" code)))))
|
(t (error (format "mu server process received signal %d" code)))))
|
||||||
((eq status 'exit)
|
((eq status 'exit)
|
||||||
(cond
|
(cond
|
||||||
((eq code 0)
|
((eq code 0)
|
||||||
(message nil)) ;; don't do anything
|
(message nil)) ;; don't do anything
|
||||||
((eq code 11)
|
((eq code 19)
|
||||||
(error "Database is locked by another process"))
|
(error "Database is locked by another process"))
|
||||||
((eq code 15)
|
(t (error "Mu server process ended with exit code %d" code))))
|
||||||
(error "Database needs upgrade; try `mu index --rebuild'"))
|
|
||||||
((eq code 19)
|
|
||||||
(error "Database empty; try indexing some messages"))
|
|
||||||
(t (error "Mu server process ended with exit code %d" code))))
|
|
||||||
(t
|
(t
|
||||||
(error "Something bad happened to the mu server process")))))
|
(error "Something bad happened to the mu server process")))))
|
||||||
|
|
||||||
(defun mu4e~docid-msgid-param (docid-or-msgid)
|
(defun mu4e~docid-msgid-param (docid-or-msgid)
|
||||||
"Construct a backend parameter based on DOCID-OR-MSGID."
|
"Construct a backend parameter based on DOCID-OR-MSGID."
|
||||||
|
|
|
@ -802,17 +802,20 @@ When successful, call FUNC (if non-nil) afterwards."
|
||||||
(lambda (props)
|
(lambda (props)
|
||||||
(setq mu4e~server-props props) ;; save props from the server
|
(setq mu4e~server-props props) ;; save props from the server
|
||||||
(let ((version (plist-get props :version))
|
(let ((version (plist-get props :version))
|
||||||
(doccount (plist-get props :doccount)))
|
(doccount (plist-get props :doccount)))
|
||||||
(mu4e~check-requirements)
|
(mu4e~check-requirements)
|
||||||
(when func (funcall func))
|
(when func (funcall func))
|
||||||
|
(when (zerop doccount)
|
||||||
|
(mu4e-message "Store is empty; (re)indexing. This can take a while.");
|
||||||
|
(mu4e-update-index))
|
||||||
(when (and mu4e-update-interval (null mu4e~update-timer))
|
(when (and mu4e-update-interval (null mu4e~update-timer))
|
||||||
(setq mu4e~update-timer
|
(setq mu4e~update-timer
|
||||||
(run-at-time
|
(run-at-time
|
||||||
0 mu4e-update-interval
|
0 mu4e-update-interval
|
||||||
(lambda () (mu4e-update-mail-and-index
|
(lambda () (mu4e-update-mail-and-index
|
||||||
mu4e-index-update-in-background)))))
|
mu4e-index-update-in-background)))))
|
||||||
(mu4e-message "Started mu4e with %d message%s in store"
|
(mu4e-message "Started mu4e with %d message%s in store"
|
||||||
doccount (if (= doccount 1) "" "s"))))))
|
doccount (if (= doccount 1) "" "s"))))))
|
||||||
;; wake up server
|
;; wake up server
|
||||||
(mu4e~proc-ping)
|
(mu4e~proc-ping)
|
||||||
;; maybe request the list of contacts, automatically refresh after
|
;; maybe request the list of contacts, automatically refresh after
|
||||||
|
|
Loading…
Reference in New Issue