mu4e: automatically rebuild database when possible

This commit is contained in:
Dirk-Jan C. Binnema 2019-07-28 14:28:01 +03:00
parent 8f24b4103a
commit 26dca831c6
2 changed files with 26 additions and 26 deletions

View File

@ -254,9 +254,10 @@ Start the process if needed."
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
(let* ((process-connection-type nil) ;; use a pipe
(args '("server"))
(args (append args (when mu4e-mu-home
(list (concat "--muhome=" mu4e-mu-home))))))
(args (append args (when mu4e-mu-home (list (concat "--muhome=" mu4e-mu-home)))))
(args (append args (list (concat "--maildir=" mu4e-maildir)))))
(setq mu4e~proc-buf "")
(message "%S" args)
(setq mu4e~proc-process (apply 'start-process
mu4e~proc-name mu4e~proc-name
mu4e-mu-binary args))
@ -301,12 +302,8 @@ Start the process if needed."
(cond
((eq code 0)
(message nil)) ;; don't do anything
((eq code 11)
(error "Database is locked by another process"))
((eq code 15)
(error "Database needs upgrade; try `mu index --rebuild'"))
((eq code 19)
(error "Database empty; try indexing some messages"))
(error "Database is locked by another process"))
(t (error "Mu server process ended with exit code %d" code))))
(t
(error "Something bad happened to the mu server process")))))

View File

@ -805,6 +805,9 @@ When successful, call FUNC (if non-nil) afterwards."
(doccount (plist-get props :doccount)))
(mu4e~check-requirements)
(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))
(setq mu4e~update-timer
(run-at-time