Commit aec0350c authored by Eric Timmons's avatar Eric Timmons

Add INDEX-SYNC generic function

parent f638af4d
......@@ -22,6 +22,7 @@
#:index-projects
#:index-release-data-missing
#:index-save
#:index-sync
#:index-system
#:index-system-class
#:index-system-file-class
......@@ -114,6 +115,11 @@ signaled."))
(:documentation
"Save modifications to INDEX to persistent storage."))
(defgeneric index-sync (index)
(:documentation
"If INDEX is backed by a dual object store, sync all objects into the
secondary."))
(defgeneric index-system (index system-name &optional error)
(:documentation
"Return the system with the name SYSTEM-NAME.
......
......@@ -141,6 +141,22 @@ object, otherwise error."
(with-clpi-io-syntax ()
(pprint plist s)))))
(defmethod index-sync ((index index))
(let ((object-store (index-object-store index)))
(when (typep object-store 'dual-object-store)
(dual-object-store-update-object object-store "clpi-version")
(dual-object-store-update-object object-store "index")
(dolist (p (index-projects index))
(dual-object-store-update-object object-store (project-object-path p "repo"))
(dual-object-store-update-object object-store (project-object-path p "authors"))
(dual-object-store-update-object object-store (project-object-path p "maintainers"))
(dual-object-store-update-object object-store (project-object-path p "homepage"))
(dual-object-store-update-object object-store (project-object-path p "releases-object-version"))
(dual-object-store-update-object object-store (project-object-path p "version-scheme"))
(dual-object-store-update-object object-store (project-releases-path p)))
(dolist (s (index-systems index))
(dual-object-store-update-object object-store (system-object-path s "primary-project"))))))
(defmethod index-system ((index index) system-name &optional (error t))
(multiple-value-bind (value exists-p)
(gethash system-name (index-system-ht index))
......
......@@ -91,18 +91,3 @@ older than 60 minutes old."))
(* 60 60)))
:binary-p binary-p
:offset offset)))))))
;; (defun dual-index-sync (object-store)
;; "Ensure that every object is present in OBJECT-STORE's secondary."
;; (dual-object-store-update-object object-store "clpi-version")
;; (dual-object-store-update-object object-store "index")
;; (dolist (p (index-projects object-store))
;; (dual-object-store-update-object object-store (project-object-path p "repo"))
;; (dual-object-store-update-object object-store (project-object-path p "authors"))
;; (dual-object-store-update-object object-store (project-object-path p "maintainers"))
;; (dual-object-store-update-object object-store (project-object-path p "homepage"))
;; (dual-object-store-update-object object-store (project-object-path p "releases-object-version"))
;; (dual-object-store-update-object object-store (project-object-path p "version-scheme"))
;; (dual-object-store-update-object object-store (project-releases-path p)))
;; (dolist (s (index-systems object-store))
;; (dual-object-store-update-object object-store (system-object-path s "primary-project"))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment