Skip to content

Commit 39afc29

Browse files
committed
check EnableCleanup
1 parent c852498 commit 39afc29

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎Plugin.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,14 @@ public class Plugin : BasePluginSimpleUI<SmartTagsConfig>
2222
public Plugin(IApplicationHost applicationHost) : base(applicationHost)
2323
{
2424
Instance = this;
25+
26+
// === 核心逻辑:重启后自动关闭清理开关 ===
27+
// 注意:此时配置可能已经从 XML 加载了,我们需要检查并覆盖它
28+
var config = Configuration;
29+
if (config.EnableCleanup)
30+
{
31+
config.EnableCleanup = false;
32+
SaveConfiguration(); // 强制保存回磁盘,确保 UI 上显示为关闭
33+
}
2534
}
2635
}

‎SmartTagsCleanupTask.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public async Task Execute(CancellationToken cancellationToken, IProgress<double>
5050
_logger.Info("[SmartTags] Cleanup 开始执行回滚任务...");
5151
var config = Plugin.Instance?.Configuration;
5252

53+
// === 安全检查 ===
54+
// 注意:使用了 MetadataProviders.Tmdb (虽然这里主要用 config 检查)
55+
if (config == null || !config.EnableCleanup)
56+
{
57+
_logger.Warn("[SmartTags] Cleanup 任务被拒绝执行!");
58+
_logger.Warn("[SmartTags] Cleanup 【危险】清理开关未开启。请先在插件设置中勾选 '启用清理任务' 并保存,然后再次运行此任务。");
59+
return;
60+
}
61+
62+
_logger.Info("[SmartTags] Cleanup 安全检查通过,开始执行回滚逻辑...");
63+
5364
// 1. 读取 TMDB 缓存文件 (用于精准回滚原产地标签)
5465
var cachePath = Path.Combine(_appPaths.PluginConfigurationsPath, "SmartTags_TmdbCache.json");
5566
Dictionary<string, TmdbCacheData>? cache = null;

‎SmartTagsConfig.cs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ public class SmartTagsConfig : EditableOptionsBase
2929

3030
[DisplayName("年代标签格式")]
3131
[Description("设置年代标签的格式,{0} 代表年代数字(如80, 90, 00)")]
32-
public string DecadeTagFormat { get; set; } = "{0}年代";
32+
public string DecadeTagFormat { get; set; } = "{0}年代";
33+
34+
[DisplayName("启用清理任务")]
35+
[Description("慎重!执行 '清除SmartTags生成的标签' 任务。此开关在 Emby 重启后会自动关闭。")]
36+
public bool EnableCleanup { get; set; } = false;
3337
}

0 commit comments

Comments
 (0)