Files
Auto_Bangumi/docs/en/dev/plugins/points/conflict-policy.md
Estrella Pan 3258fcca4b docs(4.0-P7): 插件开发文档拆分为总览加每个扩展点一页,补齐中英日三语
- docs/dev/plugins.md 改为总览与导航,旧内容拆入 docs/dev/plugins/
- 新增核心概念、配置表单、事件、前端挂载点、命令行、签名与分发、内置插件、示例页
- 每个扩展点一页,侧边栏由页面表生成
- 改正旧文档中下载器配置、hardlink path_map 与补链按钮的过时描述
2026-10-08 14:51:00 +02:00

19 lines
1.4 KiB
Markdown

# Conflict Policy (conflict_policy)
When the canonical file name of a new torrent is already used by another torrent, this policy decides to keep the old one or to replace it. A typical case is a v2 release of the same episode. `@provider(points.CONFLICT_POLICY, id=...)` returns a `ConflictPolicy`.
```python
from ab_sdk.rename import ConflictDecision, ConflictRequest
class ReplaceUpgradesOnly:
def decide(self, request: ConflictRequest) -> ConflictDecision:
if request.strict_upgrade:
return ConflictDecision("replace")
return ConflictDecision("hold", "not a higher version of the same release")
```
- `ConflictRequest`: `target_path`, `incoming` (the new torrent), `owners` (the torrents that use the name), `strict_upgrade` (the only owner is the same release as the new torrent and the new torrent has a higher version number).
- `hold` keeps the old file and the new torrent waits. AB shows the `reason` to the user. `replace` **deletes the old task and its files**.
- The host executes `replace` only when there is one owner, both torrents have a single file and both have a complete parsed identity. In all other cases AB treats the result as `hold`.
- The host has `hold` and `replace`. They are the two options of the setting "revision conflict policy". `plugins.slots.conflict_policy` selects the policy (default `hold`). If the selected id is not registered, AB uses `hold`.