(use ugarit-vfs) (define ((get-parents graph) key) (third (assoc key graph))) (define ((get-props graph) key) (list (cons 'mtime (second (assoc key graph))))) (define (kons key name props knil) (cons key knil)) (define (test-fold name graph root-key expected) (pp (reverse ;; Reverse, as fold results are back to front (fold-history** (get-parents graph) (get-props graph) root-key kons '())))) ;; Simple linear cases (test-fold "Single Element" '(("a" 1 ())) "a" '("a")) (test-fold "Two elements, ignore 1" '(("a" 1 ()) ("b" 2 ("a"))) "a" '("a")) (test-fold "Two elements" '(("a" 1 ()) ("b" 2 ("a"))) "b" '("b" "a")) (test-fold "Three elements" '(("a" 1 ()) ("b" 2 ("a")) ("c" 3 ("b"))) "c" '("c" "b" "a")) (test-fold "Simple fork" '(("a" 1 ()) ("b" 2 ()) ("c" 3 ("a" "b"))) "c" '("c" "b" "a")) (use ugarit-api) (define be (open-vault '((storage "backend-fs splitlog /tmp /tmp/metadata") (file-cache "/tmp/file-cache")))) ; Import a directory tree (define-values (dir-key dir-reused? dir-files dir-bytes) (call-with-context-support (vault-global-directory-rules be) (lambda () (store-directory! be "artwork")))) (printf "Imported content: ~S ~S\n" dir-key dir-reused?) (define ae (make-archive-entry dir-key dir-reused? '((name . "test") (mime-type . "inode/directory")))) (printf "key: ~S reused: ~S alist: ~S\n" (archive-entry-key ae) (archive-entry-key-reused? ae) (archive-entry-alist ae)) (define import-key (tag-archive-import! be "test" ; Archive tag name (list ae) ; List of entries '((import . "test")) ; Import metadata #f)) ; Optional job (for stats logging) (printf "Archive import: ~S\n" import-key) (printf "Searching archive\n") (for-each (lambda (ae) (printf "Found key: ~S reused: ~S alist: ~S\n" (archive-entry-key ae) (archive-entry-key-reused? ae) (archive-entry-alist ae))) (search-archive be "test" ; Archive tag '(and ; Search expression (= ($ mime-type) "inode/directory") (= ($ name) "test")))) (printf "Searching for all properties...\n") (pp (list-archive-properties be "test" #t)) (printf "Searching for some properties...\n") (pp (list-archive-properties be "test" '(= ($ name) "test"))) (printf "Searching for no properties...\n") (pp (list-archive-properties be "test" #f)) (printf "Searching for mime types...\n") (pp (list-archive-property-values be "test" #t 'mime-type)) (printf "Closing vault\n") (vault-close! be)