Update library lists when a move finishes (#1)
CI / test (push) Successful in 1m14s

The Library now follows moves on both servers: an item shows "Moving to …" while it moves and "Moved to …" until the source's Jellyfin drops
it after its rescan; the list reloads when a move finishes and checks again every 20 s for a few minutes. The destination shows the new item
straight away.
This commit is contained in:
IxianPixel committed 2026-11-06 17:21:22 +00:00
1 parent 484ac50508
commit 2bd4489b1a
9 files changed
+236 -61

No files matched your search

+2
View File
@@ -484,6 +484,8 @@ pub async fn complete(state: &Shared, id: &str, req: CompleteRequest) -> anyhow:
}
}
// After a season move the show is still listed here, but smaller.
crate::sizes::forget(state, &local_folder).await;
if let Err(e) = state
.jellyfin
.media_updated(std::slice::from_ref(&export.jellyfin_folder))
+2
View File
@@ -347,6 +347,8 @@ async fn promote(state: &Shared, job: &mut Job) -> anyhow::Result<()> {
Some(season) => target_local.join(&season.folder),
None => target_local.clone(),
};
// A season changes the size of a show that may already be listed here.
crate::sizes::forget(state, &target_local).await;
job.note(format!("moved into {}", placed.display()));
job.advance(Stage::Promoted);
Ok(())
+9 -1
View File
@@ -20,7 +20,7 @@ use std::sync::Mutex;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use crate::state::Shared;
use crate::state::{AppState, Shared};
/// How often a cached size's signature is checked against the disk.
pub const RECHECK: time::Duration = time::Duration::hours(1);
@@ -151,6 +151,14 @@ async fn refresh(state: &Shared, folder: &Path) -> anyhow::Result<()> {
Ok(())
}
/// Drop the cached size of a folder a move has just changed, so the next
/// listing measures it again instead of waiting for the hourly check.
pub async fn forget(state: &AppState, folder: &Path) {
if let Err(e) = state.store.delete_folder_size(&key(folder)).await {
tracing::warn!(folder = %folder.display(), error = %e, "could not forget folder size");
}
}
fn key(p: &Path) -> String {
p.to_string_lossy().into_owned()
}