added ignore-patterns to delete

Co-authored-by: Jan Krebs <jan.krebs@student.uni-tuebingen.de>
This commit is contained in:
lukas 2020-02-26 10:44:49 +01:00
parent ba678e848f
commit 137705e81c

View file

@ -32,7 +32,7 @@
(defn filter-for-ignore-patterns (defn filter-for-ignore-patterns
[ignore-patterns source-list] [ignore-patterns source-list]
(filter #(not (re-matches ignore-patterns %)) source-list)) (filter #(not (re-matches (re-pattern ignore-patterns) %)) source-list))
(defn filter-resources-for-ignore-patterns (defn filter-resources-for-ignore-patterns
[ignore-patterns resources] [ignore-patterns resources]
@ -107,18 +107,21 @@
; TODO: Add files to keep ; TODO: Add files to keep
(s/defn delete-resources! (s/defn delete-resources!
[virtual-path :- s/Str] ([virtual-path :- s/Str] (delete-resources! virtual-path nil))
(let [resource-paths ([virtual-path :- s/Str ignore-patterns]
(reverse (let [resource-paths
(sort (reverse
(get-resource-paths-recursive (sort
(str (fs/user-dir) "/") (get-resource-paths-recursive
virtual-path (str (fs/user-dir) "/")
[""] virtual-path
:from-cp false)))] [""]
(do :from-cp false)))
(doseq [resource-path resource-paths] resource-paths-filtered (if ignore-patterns
(Files/delete (fs/absolut-path virtual-path resource-path)))))) (filter-for-ignore-patterns ignore-patterns resource-paths)
resource-paths)]
(doseq [resource-path resource-paths-filtered]
(Files/delete (fs/absolut-path virtual-path resource-path))))))
(defn copy-resources! (defn copy-resources!
[fs-prefix ;:- Prefix [fs-prefix ;:- Prefix