diff options
author | dakkar <dakkar@thenautilus.net> | 2021-12-31 16:22:58 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2021-12-31 16:22:58 +0000 |
commit | 9cc1ecf5c888eabb23e74bc3cf1615c50673ef1d (patch) | |
tree | 53c9d9d464a31e5c01149a5e1c68826386d35b08 /lib/App/MediaControl.rakumod | |
parent | some better vlc controls / status (diff) | |
download | media-control-9cc1ecf5c888eabb23e74bc3cf1615c50673ef1d.tar.gz media-control-9cc1ecf5c888eabb23e74bc3cf1615c50673ef1d.tar.bz2 media-control-9cc1ecf5c888eabb23e74bc3cf1615c50673ef1d.zip |
flush batched adds
Diffstat (limited to 'lib/App/MediaControl.rakumod')
-rw-r--r-- | lib/App/MediaControl.rakumod | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/App/MediaControl.rakumod b/lib/App/MediaControl.rakumod index 0887095..12ed948 100644 --- a/lib/App/MediaControl.rakumod +++ b/lib/App/MediaControl.rakumod @@ -45,7 +45,11 @@ class App::MediaControl { start react { whenever scan-dir($root) -> $item { when $item ~~ $root {} - when $item ~~ ScanDir::End { $!db.remove-unseen() } + when $item ~~ ScanDir::End { + $!db.remove-unseen(); + $to-add.done(); + $to-add = Nil; + } my $path = $item.parent.relative($root); $path = '' if $path eq '.'; @@ -56,7 +60,12 @@ class App::MediaControl { } else { my $is-dir = $item.d; - $to-add.emit(%(:$path,:$name,:$is-dir)); + with $to-add { + .emit(%(:$path,:$name,:$is-dir)); + } + else { + $!db.add-entries([%(:$path,:$name,:$is-dir)]); + } } } whenever $to-add.Supply.batch(:100elems,:2seconds) -> $items { |