Fix directorysizes stuff
This commit is contained in:
@ -10,8 +10,10 @@
|
||||
#:parse-trashinfo-file)
|
||||
(:import-from #:cl-xdg-trash/mountpoints
|
||||
#:file-or-dir-namestring
|
||||
#:ensure-directory-pathname
|
||||
#:ensure-nonwild-pathname)
|
||||
(:import-from #:cl-xdg-trash/directorysizes
|
||||
#:list-directory
|
||||
#:read-directorysizes-for-trash-directory
|
||||
#:write-directorysizes-for-trash-directory)
|
||||
(:use #:cl #:clash/parse-date #:clash/format)
|
||||
@ -216,7 +218,12 @@ The following suffixes are recognized (in additon to \"B\"):
|
||||
:flag
|
||||
:key :size-help
|
||||
:description "print information about size ranges"
|
||||
:long-name "size-help"))))
|
||||
:long-name "size-help")
|
||||
(clingon:make-option
|
||||
:flag
|
||||
:key :no-warnings
|
||||
:description "don't print warning messages"
|
||||
:long-name "no-warnings"))))
|
||||
|
||||
(declaim (inline compare-trashinfo-to-string))
|
||||
(defun compare-trashinfo-to-string (trashinfo filter full-path exact
|
||||
@ -271,7 +278,7 @@ string."
|
||||
"Return a list of all trash directories, except those excluded by CMD."
|
||||
(append (unless (clingon:getopt cmd :only-explicit-dirs)
|
||||
(set-difference (cl-xdg-trash:list-trash-directories)
|
||||
(mapcar #'uiop:ensure-directory-pathname
|
||||
(mapcar #'ensure-directory-pathname
|
||||
(clingon:getopt cmd :ignored-trashes))
|
||||
:test #'uiop:pathname-equal))
|
||||
(mapcar #'ensure-nonwild-pathname
|
||||
@ -744,6 +751,7 @@ return a list of many indices instead."
|
||||
;; Empty command
|
||||
(defun empty/handler (cmd)
|
||||
"Handler for the \"empty\" subcommand."
|
||||
(setq *prune-directorysizes* t)
|
||||
(let* ((dir-wise (clingon:getopt cmd :directory-wise))
|
||||
(dry-run (clingon:getopt cmd :dry-run))
|
||||
(quiet (clingon:getopt cmd :quiet))
|
||||
@ -754,12 +762,17 @@ return a list of many indices instead."
|
||||
(if dir-wise
|
||||
(loop with objs-arr = (coerce objs 'vector)
|
||||
for i in indices
|
||||
do (mark-directorysizes-dirty (car (aref objs-arr i)))
|
||||
do (dolist (info (cdr (aref objs-arr i)))
|
||||
(cl-xdg-trash:empty-file info :dry-run dry-run)))
|
||||
(cl-xdg-trash:empty-file info :dry-run dry-run
|
||||
:update-directorysizes nil)))
|
||||
(loop with infos-arr = (coerce objs 'vector)
|
||||
for i in indices
|
||||
do (mark-directorysizes-dirty
|
||||
(trashinfo-trash-directory (aref infos-arr i)))
|
||||
do (cl-xdg-trash:empty-file (aref infos-arr i)
|
||||
:dry-run dry-run))))))
|
||||
:dry-run dry-run
|
||||
:update-directorysizes nil))))))
|
||||
|
||||
(defun empty/options ()
|
||||
"Return options for the \"empty\" subcommand."
|
||||
@ -921,10 +934,9 @@ return a list of many indices instead."
|
||||
(parse-trashinfo-file
|
||||
dir (file-or-dir-namestring path))
|
||||
(error () nil)))
|
||||
(uiop:directory*
|
||||
(merge-pathnames uiop:*wild-file-for-directory*
|
||||
(uiop:ensure-directory-pathname
|
||||
(merge-pathnames "files" dir))))))
|
||||
(list-directory
|
||||
(ensure-directory-pathname
|
||||
(merge-pathnames "files" dir)))))
|
||||
(format t "~A~:[~%~;~A~]"
|
||||
(uiop:native-namestring missing) null #\Nul)))))
|
||||
|
||||
@ -992,6 +1004,11 @@ return a list of many indices instead."
|
||||
|
||||
|
||||
;; Toplevel command
|
||||
(defun toplevel/post-hook (cmd)
|
||||
"Post-command hook for the toplevel command."
|
||||
(declare (ignore cmd))
|
||||
(flush-directorysizes-cache))
|
||||
|
||||
(defun toplevel/command ()
|
||||
"Return the toplevel command."
|
||||
(clingon:make-command
|
||||
@ -1007,7 +1024,8 @@ return a list of many indices instead."
|
||||
(empty/command)
|
||||
(size/command)
|
||||
(missing/command))
|
||||
:handler #'handle-toplevel-with-subcommands))
|
||||
:handler #'handle-toplevel-with-subcommands
|
||||
:post-hook #'toplevel/post-hook))
|
||||
|
||||
(defparameter *toplevel/help-option*
|
||||
(clingon:make-option
|
||||
@ -1029,7 +1047,9 @@ return a list of many indices instead."
|
||||
(error 'clingon:exit-error :code 0))
|
||||
(when (clingon:getopt cmd :size-help)
|
||||
(print-byte-range-help t)
|
||||
(error 'clingon:exit-error :code 0)))
|
||||
(error 'clingon:exit-error :code 0))
|
||||
(when (clingon:getopt cmd :no-warnings)
|
||||
(setq *no-warnings* t)))
|
||||
|
||||
(defun toplevel (&optional (args () argsp))
|
||||
"Program entry point.
|
||||
@ -1040,8 +1060,7 @@ Args can be supplied to facilitate testing in SLIME."
|
||||
*toplevel/help-option*)))
|
||||
(if argsp
|
||||
(clingon:run (toplevel/command) args)
|
||||
(clingon:run (toplevel/command)))
|
||||
(flush-directorysizes-cache)))
|
||||
(clingon:run (toplevel/command)))))
|
||||
|
||||
;; Used from the build system
|
||||
(defun make-markdown-doc ()
|
||||
|
||||
Reference in New Issue
Block a user