1
0
Fork 0

- defined alias for 'zip-file-p' as 'gempub-file-p'.

This commit is contained in:
cage 2021-08-27 12:15:12 +02:00
parent 2bf39530c2
commit 6a91bd4da7
3 changed files with 7 additions and 4 deletions

View File

@ -71,7 +71,7 @@
(define-constant +metadata-entry-name "metadata.txt" :test #'string=)
(defun extract-metadata (zip-file)
(when (zip-info:zip-file-p zip-file :ignore-errors t)
(when (gempub:gempub-file-p zip-file :ignore-errors t)
(let ((entries (zip-info:list-entries zip-file)))
(when (find +metadata-entry-name entries :test #'String=)
(when-let ((metadata-raw (os-utils:unzip-single-file zip-file
@ -97,11 +97,13 @@
(getf metadata :version)
(getf metadata :cover))))
(defalias gempub-file-p #'zip-info:zip-file-p)
(defun sync-library (&key (notify nil))
(when notify
(ui:notify (format nil (_ "Syncing gempub library."))))
(let ((all-known (db:all-gempub-metadata))
(all-gempub-files (remove-if-not (lambda (a) (zip-info:zip-file-p a
(all-gempub-files (remove-if-not (lambda (a) (gempub:gempub-file-p a
:ignore-errors t))
(fs:collect-files/dirs (swconf:gempub-library-directory))))
(removed-known '())
@ -109,7 +111,7 @@
(loop for known in all-known do
(let ((local-uri (db:row-local-uri known)))
(when (not (and (fs:file-exists-p local-uri)
(zip-info:zip-file-p local-uri :ignore-errors t)))
(gempub:gempub-file-p local-uri :ignore-errors t)))
(push local-uri removed-known)
(db:gempub-metadata-delete local-uri))))
(loop for gempub-file in (mapcar #'uri:normalize-path all-gempub-files) do

View File

@ -2449,6 +2449,7 @@
(:shadowing-import-from :text-utils :split-lines)
(:shadowing-import-from :misc :random-elt :shuffle)
(:export
:gempub-file-p
:extract-metadata
:sync-library
:parse-search-gempub

View File

@ -1131,7 +1131,7 @@
(gemini-viewer:push-url-to-history window index-path)
(refresh-gemini-message-window links raw-text ir nil)
(windows:draw window)))
((zip-info:zip-file-p local-path :ignore-errors t)
((gempub:gempub-file-p local-path :ignore-errors t)
(let ((temp-directory (fs:temporary-directory)))
(os-utils:unzip-file local-path temp-directory)
(let* ((library-entry (db:gempub-metadata-find local-path))