37 lines
1.8 KiB
Common Lisp
37 lines
1.8 KiB
Common Lisp
#-quicklisp
|
|
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
|
|
(user-homedir-pathname))))
|
|
(when (probe-file quicklisp-init)
|
|
(load quicklisp-init)))
|
|
(ql:quickload :loop :silent t)
|
|
(in-package #:loop)
|
|
(defun verify-index-inodes ()
|
|
"Iterates over all group articles and prints whether they share an inode with index/."
|
|
(loop for path in (in-groups (directory "**/*"))
|
|
do (let* ((dir-list (pathname-directory path))
|
|
(g (when dir-list (str:trim (first (last dir-list)))))
|
|
(i (pathname-name path))
|
|
(i-str (when i (str:trim i))))
|
|
;; ignore metadata and directories
|
|
(when (and g i-str (parse-integer i-str :junk-allowed t))
|
|
(let ((mid (ignore-errors (get-mid-from-path path))))
|
|
(if (or (null mid) (zerop (length (str:trim mid))))
|
|
(format t "no-mid ~a/~a couldn't find message-id~%" g i-str)
|
|
(let* ((hash (index-hash mid))
|
|
(idx-path (index-path hash))
|
|
(grp-inode (get-file-inode path))
|
|
(idx-inode (get-file-inode idx-path)))
|
|
(cond
|
|
((null idx-inode)
|
|
(stdout "no-index ~a/~a mid ~a hashes-to ~a~%"
|
|
g i-str mid idx-path))
|
|
((= grp-inode idx-inode)
|
|
(stdout "okay ~a/~a shares-inode ~a = ~a hashed-at ~a~%"
|
|
g i-str grp-inode idx-inode idx-path))
|
|
(t
|
|
(stdout "mismatch ~a/~a inode ~a =/= inode ~a hash ~a~%"
|
|
g i-str grp-inode idx-inode idx-path))))))))))
|
|
|
|
(defun verify-index ()
|
|
(verify-index-inodes))
|
|
(verify-index)
|