From 9042e92f96dd39430567287d95204730fb434c9f Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Fri, 18 Oct 2024 14:03:56 +0200 Subject: [PATCH] fix assets copy, load correct storage for media page --- docker/Dockerfile | 7 ++----- docker/nonfree.Dockerfile | 7 ++----- docker/nvidia.Dockerfile | 7 ++----- engine/src/utils/channels.rs | 12 +++++------- engine/src/utils/mod.rs | 4 +++- frontend/components/ConfigChannel.vue | 3 +++ 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1079654b..1d65f605 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,9 +13,6 @@ COPY <<-EOT /run.sh if [ ! -f /db/ffplayout.db ]; then ffplayout -i -u admin -p admin -m contact@example.com --storage "/tv-media" --playlists "/playlists" --public "/public" --logs "/logging" --mail-smtp "mail.example.org" --mail-user "admin@example.org" --mail-password "abcd" --mail-starttls - - mkdir /tv-media/1 - cp -r /00-assets /tv-media/1/ fi /usr/bin/ffplayout -l "0.0.0.0:8787" @@ -31,8 +28,8 @@ RUN [[ -f "/tmp/ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz cd /tmp && \ tar xf "ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" && \ cp ffplayout /usr/bin/ && \ - mkdir /00-assets && \ - cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /00-assets/ && \ + mkdir -p /usr/share/ffplayout/ && \ + cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /usr/share/ffplayout/ && \ rm -rf /tmp/* && \ mkdir ${DB} diff --git a/docker/nonfree.Dockerfile b/docker/nonfree.Dockerfile index 673f6484..7e4f46d0 100644 --- a/docker/nonfree.Dockerfile +++ b/docker/nonfree.Dockerfile @@ -15,9 +15,6 @@ COPY <<-EOT /run.sh if [ ! -f /db/ffplayout.db ]; then ffplayout -i -u admin -p admin -m contact@example.com --storage "/tv-media" --playlists "/playlists" --public "/public" --logs "/logging" --mail-smtp "mail.example.org" --mail-user "admin@example.org" --mail-password "abcd" --mail-starttls - - mkdir /tv-media/1 - cp -r /00-assets /tv-media/1/ fi /usr/bin/ffplayout -l "0.0.0.0:8787" @@ -33,8 +30,8 @@ RUN [[ -f "/tmp/ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz cd /tmp && \ tar xf "ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" && \ cp ffplayout /usr/bin/ && \ - mkdir /00-assets && \ - cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /00-assets/ && \ + mkdir -p /usr/share/ffplayout/ && \ + cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /usr/share/ffplayout/ && \ rm -rf /tmp/* && \ mkdir ${DB} diff --git a/docker/nvidia.Dockerfile b/docker/nvidia.Dockerfile index 4e1e0ac3..1c9b24fe 100644 --- a/docker/nvidia.Dockerfile +++ b/docker/nvidia.Dockerfile @@ -205,9 +205,6 @@ COPY <<-EOT /run.sh if [ ! -f /db/ffplayout.db ]; then ffplayout -i -u admin -p admin -m contact@example.com --storage "/tv-media" --playlists "/playlists" --public "/public" --logs "/logging" --mail-smtp "mail.example.org" --mail-user "admin@example.org" --mail-password "abcd" --mail-starttls - - mkdir /tv-media/1 - cp -r /00-assets /tv-media/1/ fi /usr/bin/ffplayout -l "0.0.0.0:8787" @@ -220,8 +217,8 @@ RUN [[ -f "/tmp/ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz cd /tmp && \ tar xf "ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" && \ cp ffplayout /usr/bin/ && \ - mkdir /00-assets && \ - cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /00-assets/ && \ + mmkdir -p /usr/share/ffplayout/ && \ + cp assets/dummy.vtt assets/logo.png assets/DejaVuSans.ttf assets/FONT_LICENSE.txt /usr/share/ffplayout/ && \ rm -rf /tmp/* && \ mkdir ${DB} diff --git a/engine/src/utils/channels.rs b/engine/src/utils/channels.rs index 252b8c7e..36e1d87c 100644 --- a/engine/src/utils/channels.rs +++ b/engine/src/utils/channels.rs @@ -35,14 +35,8 @@ pub async fn create_channel( target_channel: Channel, ) -> Result { let channel = handles::insert_channel(conn, target_channel).await?; - let storage_path = PathBuf::from(channel.storage.clone()); handles::new_channel_presets(conn, channel.id).await?; - - if let Err(e) = copy_assets(&storage_path).await { - error!("{e}"); - }; - handles::update_channel(conn, channel.id, channel.clone()).await?; let output_param = "-c:v libx264 -crf 23 -x264-params keyint=50:min-keyint=25:scenecut=-1 -maxrate 1300k -bufsize 2600k -preset faster -tune zerolatency -profile:v Main -level 3.1 -c:a aac -ar 44100 -b:a 128k -flags +cgop -f hls -hls_time 6 -hls_list_size 600 -hls_flags append_list+delete_segments+omit_endlist -hls_segment_filename live/stream-%d.ts live/stream.m3u8".to_string(); @@ -52,7 +46,11 @@ pub async fn create_channel( let config = get_config(conn, channel.id).await?; let m_queue = Arc::new(Mutex::new(MailQueue::new(channel.id, config.mail.clone()))); - let manager = ChannelManager::new(Some(conn.clone()), channel.clone(), config); + let manager = ChannelManager::new(Some(conn.clone()), channel.clone(), config.clone()); + + if let Err(e) = copy_assets(&PathBuf::from(&config.storage.path)).await { + error!("{e}"); + }; controllers .lock() diff --git a/engine/src/utils/mod.rs b/engine/src/utils/mod.rs index b083a8d1..8365aa35 100644 --- a/engine/src/utils/mod.rs +++ b/engine/src/utils/mod.rs @@ -336,7 +336,7 @@ pub async fn copy_assets(storage_path: &Path) -> Result<(), std::io::Error> { let font_target = target.join("DejaVuSans.ttf"); let logo_target = target.join("logo.png"); - fs::create_dir(&target).await?; + fs::create_dir_all(&target).await?; fs::copy(&dummy_source, &dummy_target).await?; fs::copy(&font_source, &font_target).await?; fs::copy(&logo_source, &logo_target).await?; @@ -365,6 +365,8 @@ pub async fn copy_assets(storage_path: &Path) -> Result<(), std::io::Error> { } } } + } else { + error!("Storage path {storage_path:?} not exists!"); } Ok(()) diff --git a/frontend/components/ConfigChannel.vue b/frontend/components/ConfigChannel.vue index 5061b7b6..ef806ae1 100644 --- a/frontend/components/ConfigChannel.vue +++ b/frontend/components/ConfigChannel.vue @@ -116,6 +116,7 @@ const { t } = useI18n() const authStore = useAuth() const configStore = useConfig() +const mediaStore = useMedia() const indexStore = useIndex() const { i } = storeToRefs(useConfig()) @@ -220,6 +221,7 @@ async function addUpdateChannel() { await configStore.getAdvancedConfig() await configStore.getPlayoutConfig() await configStore.getUserConfig() + await mediaStore.getTree('') } } @@ -244,6 +246,7 @@ async function deleteChannel() { await configStore.getAdvancedConfig() await configStore.getPlayoutConfig() await configStore.getUserConfig() + await mediaStore.getTree('') if (response.status === 200) { indexStore.msgAlert('success', t('config.errorChannelDelete'), 2)