commit 09038f7

chld  ·  2026-09-12 14:49:08 +0000 UTC
parent a2d5285
file removal done
1 files changed,  +24, -2
+24, -2
 1@@ -57,19 +57,41 @@
 2 				      (string-split (read-string f) #\newline)
 3 				      )
 4 				    )))
 5+	 (rl '())
 6 	 )
 7     (unless (file-exists? pl) (die (format #f "package ~a~a~a does not have a lock file (not installed?)" "\x1b[33m" pkg "\x1b[0m") 2))
 8 
 9     (let fp ((n 0))
10       (unless (= n (length pf))
11 	(when (eq? (stat:type (stat (list-ref pf n))) 'regular)
12-	  (format #t "~a file~%" (list-ref pf n)))
13+	  (format #t "~a file " (list-ref pf n))
14+	  (delete-file (list-ref pf n))
15+	  (format #t "rm~%")
16+
17+	  ;; add to deleted list
18+	  (set! rl
19+		(cons (list-ref pf n) rl)
20+		)
21+	  )
22 	(fp (+ n 1))))
23     
24     (let dp ((n 0))
25       (unless (= n (length pf))
26+	;; remove directories not in deleted list
27+	(unless (member (list-ref pf n) rl)
28 	(when (eq? (stat:type (stat (list-ref pf n))) 'directory)
29-	  (format #t "~a dir~%" (list-ref pf n)))
30+	  (format #t "~a dir " (list-ref pf n))
31+	  
32+	  (catch 'system-error
33+		 (lambda ()
34+		   (rmdir (list-ref pf n))
35+		   (format #t "rmdir~%")
36+		   )
37+		 (lambda (key . args)
38+		   (format #t "fail~%")
39+		   )
40+		 )
41+	  ))
42 	(dp (+ n 1))))
43     )
44   )