diff options
| author | Eric Abrahamsen | 2019-06-16 19:14:25 -0700 |
|---|---|---|
| committer | Eric Abrahamsen | 2019-06-16 19:14:25 -0700 |
| commit | 2815174f100798c6c84f4098dc6eb28336aa951e (patch) | |
| tree | 29ed9ce129f992a98f42aa6b5df6b0dbcce3280d | |
| parent | 8c56eb0525c22acee713434840c2ef0a1a3811cc (diff) | |
| download | emacs-2815174f100798c6c84f4098dc6eb28336aa951e.tar.gz emacs-2815174f100798c6c84f4098dc6eb28336aa951e.zip | |
Prevent the Gnus registry from being loaded twice at startup
* lisp/gnus/gnus-registry.el (gnus-registry-load): Check if the
registry is already loaded, and don't load again unless new optional
FORCE argument is non-nil.
(gnus-registry-clear): New function to clear the registry, added as
a Gnus shutdown. Now that loading doesn't unilaterally reset the
registry, we need to make sure it is reloaded when Gnus is.
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 6e549cf246d..e488858ebe0 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -307,33 +307,40 @@ This is not required after changing `gnus-registry-cache-file'." | |||
| 307 | (gnus-message 4 "Remaking the Gnus registry") | 307 | (gnus-message 4 "Remaking the Gnus registry") |
| 308 | (setq gnus-registry-db (gnus-registry-make-db)))) | 308 | (setq gnus-registry-db (gnus-registry-make-db)))) |
| 309 | 309 | ||
| 310 | (defun gnus-registry-load () | 310 | (defun gnus-registry-load (&optional force) |
| 311 | "Load the registry from the cache file." | 311 | "Load the registry from the cache file. |
| 312 | If the registry is already loaded, don't reload unless FORCE is | ||
| 313 | non-nil." | ||
| 312 | (interactive) | 314 | (interactive) |
| 313 | (let ((file gnus-registry-cache-file)) | 315 | (when (or force |
| 314 | (condition-case nil | 316 | ;; The registry is loaded by both |
| 315 | (gnus-registry-read file) | 317 | ;; `gnus-registry-initialize' and the read-newsrc hook. |
| 316 | (file-error | 318 | ;; Don't load twice. |
| 317 | ;; Fix previous mis-naming of the registry file. | 319 | (null (eieio-object-p gnus-registry-db))) |
| 318 | (let ((old-file-name | 320 | (let ((file gnus-registry-cache-file)) |
| 319 | (concat (file-name-sans-extension | 321 | (condition-case nil |
| 320 | gnus-registry-cache-file) | 322 | (gnus-registry-read file) |
| 321 | ".eioio"))) | 323 | (file-error |
| 322 | (if (and (file-exists-p old-file-name) | 324 | ;; Fix previous mis-naming of the registry file. |
| 323 | (yes-or-no-p | 325 | (let ((old-file-name |
| 324 | (format "Rename registry file from %s to %s? " | 326 | (concat (file-name-sans-extension |
| 325 | old-file-name file))) | 327 | gnus-registry-cache-file) |
| 326 | (progn | 328 | ".eioio"))) |
| 327 | (gnus-registry-read old-file-name) | 329 | (if (and (file-exists-p old-file-name) |
| 328 | (setf (oref gnus-registry-db file) file) | 330 | (yes-or-no-p |
| 329 | (gnus-message 1 "Registry filename changed to %s" file)) | 331 | (format "Rename registry file from %s to %s? " |
| 330 | (gnus-registry-remake-db t)))) | 332 | old-file-name file))) |
| 331 | (error | 333 | (progn |
| 332 | (gnus-message | 334 | (gnus-registry-read old-file-name) |
| 333 | 1 | 335 | (setf (oref gnus-registry-db file) file) |
| 334 | "The Gnus registry could not be loaded from %s, creating a new one" | 336 | (gnus-message 1 "Registry filename changed to %s" file)) |
| 335 | file) | 337 | (gnus-registry-remake-db t)))) |
| 336 | (gnus-registry-remake-db t))))) | 338 | (error |
| 339 | (gnus-message | ||
| 340 | 1 | ||
| 341 | "The Gnus registry could not be loaded from %s, creating a new one" | ||
| 342 | file) | ||
| 343 | (gnus-registry-remake-db t)))))) | ||
| 337 | 344 | ||
| 338 | (defun gnus-registry-read (file) | 345 | (defun gnus-registry-read (file) |
| 339 | "Do the actual reading of the registry persistence file." | 346 | "Do the actual reading of the registry persistence file." |
| @@ -1102,6 +1109,12 @@ only the last one's marks are returned." | |||
| 1102 | (gnus-registry-set-id-key id key val)))) | 1109 | (gnus-registry-set-id-key id key val)))) |
| 1103 | (message "Import done, collected %d entries" count)))) | 1110 | (message "Import done, collected %d entries" count)))) |
| 1104 | 1111 | ||
| 1112 | (defun gnus-registry-clear () | ||
| 1113 | "Clear the registry." | ||
| 1114 | (setq gnus-registry-db nil)) | ||
| 1115 | |||
| 1116 | (gnus-add-shutdown 'gnus-registry-clear 'gnus) | ||
| 1117 | |||
| 1105 | ;;;###autoload | 1118 | ;;;###autoload |
| 1106 | (defun gnus-registry-initialize () | 1119 | (defun gnus-registry-initialize () |
| 1107 | "Initialize the Gnus registry." | 1120 | "Initialize the Gnus registry." |