From 09604fd283bf9ef2fbea88facd7d6bacb9f4b626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Tue, 17 Mar 2026 00:35:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=85=E7=A9=BA=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=81=E5=85=A8=E9=87=8F=E5=88=B7=E6=96=B0=E6=97=B6=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E7=A9=BA=E8=B7=AF=E5=BE=84=E7=9A=84=E5=88=A0=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E5=BE=AE=E8=B0=83=E5=89=8D=E7=AB=AF=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=20(#679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/routes/video_sources/mod.rs | 16 ++++++--- crates/bili_sync/src/api/routes/videos/mod.rs | 14 +++++--- web/src/lib/components/video-card.svelte | 4 +-- web/src/routes/video-sources/+page.svelte | 25 ++++++++------ web/src/routes/videos/+page.svelte | 34 +++++++++---------- 5 files changed, 54 insertions(+), 39 deletions(-) diff --git a/crates/bili_sync/src/api/routes/video_sources/mod.rs b/crates/bili_sync/src/api/routes/video_sources/mod.rs index b7bca39..182988d 100644 --- a/crates/bili_sync/src/api/routes/video_sources/mod.rs +++ b/crates/bili_sync/src/api/routes/video_sources/mod.rs @@ -413,11 +413,17 @@ pub async fn full_sync_video_source( let warnings = if request.delete_local { let tasks = video_paths .into_iter() - .map(|path| async move { - tokio::fs::remove_dir_all(&path) - .await - .with_context(|| format!("failed to remove {path}"))?; - Result::<_, anyhow::Error>::Ok(()) + .filter_map(|path| { + if path.is_empty() { + None + } else { + Some(async move { + tokio::fs::remove_dir_all(&path) + .await + .with_context(|| format!("failed to remove {path}"))?; + Result::<_, anyhow::Error>::Ok(()) + }) + } }) .collect::>(); Some( diff --git a/crates/bili_sync/src/api/routes/videos/mod.rs b/crates/bili_sync/src/api/routes/videos/mod.rs index 2aa5144..5602be6 100644 --- a/crates/bili_sync/src/api/routes/videos/mod.rs +++ b/crates/bili_sync/src/api/routes/videos/mod.rs @@ -185,11 +185,15 @@ pub async fn clear_and_reset_video_status( .await?; txn.commit().await?; let video_info = video_info.try_into_model()?; - let warning = tokio::fs::remove_dir_all(&video_info.path) - .await - .context(format!("删除本地路径「{}」失败", video_info.path)) - .err() - .map(|e| format!("{:#}", e)); + let warning = if video_info.path.is_empty() { + None + } else { + tokio::fs::remove_dir_all(&video_info.path) + .await + .context(format!("删除本地路径「{}」失败", video_info.path)) + .err() + .map(|e| format!("{:#}", e)) + }; Ok(ApiResponse::ok(ClearAndResetVideoStatusResponse { warning, video: VideoInfo { diff --git a/web/src/lib/components/video-card.svelte b/web/src/lib/components/video-card.svelte index 7714c64..e7760f0 100644 --- a/web/src/lib/components/video-card.svelte +++ b/web/src/lib/components/video-card.svelte @@ -137,7 +137,7 @@ -
+
- + {#if source.type === 'favorite'} {:else if source.type === 'collection'} diff --git a/web/src/routes/video-sources/+page.svelte b/web/src/routes/video-sources/+page.svelte index ba1929c..b5fecb8 100644 --- a/web/src/routes/video-sources/+page.svelte +++ b/web/src/routes/video-sources/+page.svelte @@ -4,6 +4,7 @@ import { Switch } from '$lib/components/ui/switch/index.js'; import { Input } from '$lib/components/ui/input/index.js'; import { Label } from '$lib/components/ui/label/index.js'; + import { Checkbox } from '$lib/components/ui/checkbox/index.js'; import { Badge } from '$lib/components/ui/badge/index.js'; import * as Table from '$lib/components/ui/table/index.js'; import * as Tabs from '$lib/components/ui/tabs/index.js'; @@ -648,19 +649,23 @@ 全量更新视频 确定要全量更新视频源 "{fullSyncSource?.name}" 吗?
- 该操作会拉取该视频源下所有当前存在的视频,移除数据库中已不存在于该源的视频及其分页数据,无法撤销
+ >。

+ 请谨慎对“稍后再看”执行全量更新操作,因为其视频源本身就具有较强的时效性,执行全量更新可能导致大量视频被移除。
-
- - +
+
+ + +
+

+ 删除多余视频时同时删除视频对应的本地文件夹,请谨慎勾选 +

+
+ 有效性: + { + setValidationFilter(value); + resetCurrentPage(); + goto(`/${ToQuery($appStateStore)}`); + }} + onRemove={() => { + setValidationFilter(null); + resetCurrentPage(); + goto(`/${ToQuery($appStateStore)}`); + }} + /> +
状态: @@ -386,22 +402,6 @@ }} />
-
- 有效性: - { - setValidationFilter(value); - resetCurrentPage(); - goto(`/${ToQuery($appStateStore)}`); - }} - onRemove={() => { - setValidationFilter(null); - resetCurrentPage(); - goto(`/${ToQuery($appStateStore)}`); - }} - /> -
来源: