aboutsummaryrefslogtreecommitdiff
path: root/lib/App/MediaControl.rakumod
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2021-12-31 16:30:23 +0000
committerdakkar <dakkar@thenautilus.net>2021-12-31 16:30:23 +0000
commit7a8303eebd7b5419db655408c36b71a11ff02892 (patch)
treeeec34ff138170df5d624c65855ea8d8366e9a30a /lib/App/MediaControl.rakumod
parentkill note (diff)
downloadmedia-control-7a8303eebd7b5419db655408c36b71a11ff02892.tar.gz
media-control-7a8303eebd7b5419db655408c36b71a11ff02892.tar.bz2
media-control-7a8303eebd7b5419db655408c36b71a11ff02892.zip
Revert "batch inserts!"
This reverts commit d8623278929c620e22cfb943b5724c66e5f5fb91. if, inside a batch, we get both a dir and its children, the `WITH` wouldn't see the parent (it's not there yet), so the children would have `parent_id` would stay NULL
Diffstat (limited to 'lib/App/MediaControl.rakumod')
-rw-r--r--lib/App/MediaControl.rakumod17
1 files changed, 2 insertions, 15 deletions
diff --git a/lib/App/MediaControl.rakumod b/lib/App/MediaControl.rakumod
index 12ed948..641754a 100644
--- a/lib/App/MediaControl.rakumod
+++ b/lib/App/MediaControl.rakumod
@@ -41,15 +41,10 @@ class App::MediaControl {
method !start-scan() {
my $root = $.config<media><root>;
$!db.clear-seen();
- my Supplier $to-add .= new;
start react {
whenever scan-dir($root) -> $item {
when $item ~~ $root {}
- when $item ~~ ScanDir::End {
- $!db.remove-unseen();
- $to-add.done();
- $to-add = Nil;
- }
+ when $item ~~ ScanDir::End { $!db.remove-unseen() }
my $path = $item.parent.relative($root);
$path = '' if $path eq '.';
@@ -60,17 +55,9 @@ class App::MediaControl {
}
else {
my $is-dir = $item.d;
- with $to-add {
- .emit(%(:$path,:$name,:$is-dir));
- }
- else {
- $!db.add-entries([%(:$path,:$name,:$is-dir)]);
- }
+ $!db.add-entry(:$path,:$name,:$is-dir);
}
}
- whenever $to-add.Supply.batch(:100elems,:2seconds) -> $items {
- $!db.add-entries($items);
- }
}
}