summaryrefslogtreecommitdiff
path: root/lib/Ultramarine/Model/Collection.pm6
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-12-30 14:41:38 +0000
committerdakkar <dakkar@thenautilus.net>2017-12-30 14:41:38 +0000
commit375827657ffbb153d30778070a86c6873ee5b3c5 (patch)
tree02f8c66e997af4b5b9407656b4cafcd4922edfc3 /lib/Ultramarine/Model/Collection.pm6
parentmove coercions to signatures (diff)
downloadUltramarine-375827657ffbb153d30778070a86c6873ee5b3c5.tar.gz
Ultramarine-375827657ffbb153d30778070a86c6873ee5b3c5.tar.bz2
Ultramarine-375827657ffbb153d30778070a86c6873ee5b3c5.zip
handle file deletion
Diffstat (limited to 'lib/Ultramarine/Model/Collection.pm6')
-rw-r--r--lib/Ultramarine/Model/Collection.pm615
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Ultramarine/Model/Collection.pm6 b/lib/Ultramarine/Model/Collection.pm6
index e894f1c..4a09b46 100644
--- a/lib/Ultramarine/Model/Collection.pm6
+++ b/lib/Ultramarine/Model/Collection.pm6
@@ -21,20 +21,27 @@ class Ultramarine::Model::Collection {
CATCH { default { .perl.say } }
react whenever $.dirscan.scan -> $path {
when $path ~~ Ultramarine::Model::DirScanner::EndOfScan {
- # we should use this to check that all the files in
+ # we use this to check that all the files in
# the db have been seen, and delete those that haven't
- #
- # calling db.remove-unseen-files, plus db.remove-empty
+ $.db.remove-unseen-files();
$!mark-ready.keep(True);
}
when $path ~~ IO::Path & :f {
my $mtime = $path.modified.floor;
- # call db.ensure-song and db.seen-file
+ # we only care to keep track of which files we've
+ # seen during the initial scan (so we can clean up
+ # rows for files that were removed while we were
+ # not running); after that, we'll get notification
+ # of deleted files, and we'll remove those
+ $.db.seen-file(:$path) unless $.is-ready.status ~~ Kept;
unless $.db.is-up-to-date(:$path,:$mtime) {
my %metadata = $.file-class.new(:$path).metadata;
$.db.ensure-song(:$path,:$mtime,:%metadata) if %metadata.keys;
}
}
+ when $path ~~ IO::Path & :!f {
+ $.db.ensure-file-absent(:$path);
+ }
}
}
}