Function: org-persist-gc

org-persist-gc is a byte-compiled function defined in org-persist.el.gz.

Signature

(org-persist-gc)

Documentation

Remove expired or unregistered containers.

Also, remove containers associated with non-existing files.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-persist.el.gz
(defun org-persist-gc ()
  "Remove expired or unregistered containers.
Also, remove containers associated with non-existing files."
  (let (new-index (remote-files-num 0))
    (dolist (collection org-persist--index)
      (let* ((file (plist-get (plist-get collection :associated) :file))
             (file-remote (when file (file-remote-p file)))
             (persist-file (when (plist-get collection :persist-file)
                             (org-file-name-concat
                              org-persist-directory
                              (plist-get collection :persist-file))))
             (expired? (org-persist--gc-expired-p
                        (plist-get collection :expiry) collection)))
        (when persist-file
          (when file
            (when file-remote (cl-incf remote-files-num))
            (unless (if (not file-remote)
                        (file-exists-p file)
                      (pcase org-persist-remote-files
                        ('t t)
                        ('check-existence
                         (file-exists-p file))
                        ((pred numberp)
                         (<= org-persist-remote-files remote-files-num))
                        (_ nil)))
              (setq expired? t)))
          (if expired?
              (org-persist--gc-persist-file persist-file)
            (push collection new-index)))))
    (setq org-persist--index (nreverse new-index))))