aboutsummaryrefslogtreecommitdiff
path: root/lib/App/MediaControl/Web.rakumod
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-01-20 17:30:25 +0000
committerdakkar <dakkar@thenautilus.net>2024-01-20 17:35:21 +0000
commit491dc1aeab9b445ee28f972e19a1cbb4cb9f3af7 (patch)
treeb4213dfea7e02f16e286b6b814dc196c19714cdf /lib/App/MediaControl/Web.rakumod
parentquite the ScanDir supply when files are being modified (diff)
downloadmedia-control-491dc1aeab9b445ee28f972e19a1cbb4cb9f3af7.tar.gz
media-control-491dc1aeab9b445ee28f972e19a1cbb4cb9f3af7.tar.bz2
media-control-491dc1aeab9b445ee28f972e19a1cbb4cb9f3af7.zip
look at fs on demand, don't watch it
ScanDir (well, fs notifications in raku) is too slow to keep up with actual fs changes (especially when e.g. a file is being downloaded) there's actually no need to watch fs changes, we can just sync the db with the file system we look at each directory
Diffstat (limited to 'lib/App/MediaControl/Web.rakumod')
-rw-r--r--lib/App/MediaControl/Web.rakumod14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/App/MediaControl/Web.rakumod b/lib/App/MediaControl/Web.rakumod
index 77d8e05..86c748e 100644
--- a/lib/App/MediaControl/Web.rakumod
+++ b/lib/App/MediaControl/Web.rakumod
@@ -4,12 +4,12 @@ use Cro::HTTP::Router;
use Cro::WebApp::Template;
use Vlc::Client;
use Lirc::Commands;
-use App::MediaControl::DB;
+use App::MediaControl::Model;
class App::MediaControl::Web {
has Vlc::Client $.vlc is required;
has Lirc::Commands $.lirc is required;
- has App::MediaControl::DB $.db is required;
+ has App::MediaControl::Model $.model is required;
has Int $.port = 8080;
has Str $.host = '*';
has Cro::Service $!service handles <stop>;
@@ -18,11 +18,11 @@ class App::MediaControl::Web {
my $vlc = route {
post -> 'play' { await self.vlc.command('pl_play') }
post -> 'play', Int:D $id {
- my $file = self.db.get-entry($id);
+ my $file = self.model.get-entry($id);
await self.vlc.play-file(|%(
$file<path name>:p # no comma!
));
- self.db.mark-entry-watched($id);
+ self.model.mark-entry-watched($id);
}
post -> 'pause' { await self.vlc.command('pl_pause') }
post -> 'stop' { await self.vlc.command('pl_stop') }
@@ -46,14 +46,14 @@ class App::MediaControl::Web {
my $media = route {
get -> $id=Nil {
- my %reply = children => @(self.db.get-children-of($id));
+ my %reply = children => @(self.model.get-children-of($id));
with $id {
- %reply<parents> = self.db.get-parents-of($id);
+ %reply<parents> = self.model.get-parents-of($id);
};
content 'application/json', %reply;
}
get -> 'recent' {
- content 'application/json', @(self.db.get-recently-watched-folders());
+ content 'application/json', @(self.model.get-recently-watched-folders());
}
};