Skip to content

fix: (#8259)修复默认存储策略(本地存储)的配置在重启后被还原的问题 - #10253

Open
bedhere wants to merge 1 commit into
halo-dev:mainfrom
bedhere:fix/8259-preserve-default-policy
Open

bedhere wants to merge 1 commit into
halo-dev:mainfrom
bedhere:fix/8259-preserve-default-policy

Conversation

@bedhere

@bedhere bedhere commented Aug 17, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Feature
  • Bug fix
  • Improvement
  • Cleanup
  • Documentation

What this PR does / why we need it:

修复默认存储策略(default-policy)的配置在 Halo 重启后丢失的问题。

系统内置的"本地存储"策略会在每次启动时通过 ExtensionResourceInitializer
extensions/attachment-local-policy.yaml 重新初始化。此前同文件中的
default-policy-config ConfigMap 已带有 halo.run/do-not-overwrite: "true" 标签
(在 #8230 中引入),因此用户修改的存储配置数据(如存储位置)可以保留;
default-policy 本身漏加了该标签,导致每次启动时初始化器都会用内置 YAML
强制覆盖它,用户在该策略上保存的修改——例如"上传界面显示优先级"(保存在
metadata.labels["storage.halo.run/policy-priority-in-upload-ui"])以及自定义的
显示名称——在重启后都会被还原为默认值(对应 Issue #8259)。

本 PR 为 default-policy 补上与 ConfigMap 一致的
halo.run/do-not-overwrite: "true" 标签,使初始化器在启动时跳过对该策略的覆盖,
从而保留用户的修改。

Which issue(s) this PR fixes:

Fixes #8259

Special notes for your reviewer:

  • 修复方式与 Add do-not-overwrite label support for extension updates #8230 引入的 do-not-overwrite 机制完全一致,不引入新的行为变更。
  • 新增测试:
    • AttachmentLocalPolicyResourceTest:断言 default-policy 及其 ConfigMap 均带有
      halo.run/do-not-overwrite 标签(防止该保护标签将来被误删);
    • ExtensionResourceInitializerTest:新增用例验证带 do-not-overwrite 标签的扩展
      在启动初始化时不会被 update / create 覆盖。
  • 本地验证:目标测试修复前失败(FAIL)、修复后通过(PASS);
    ./gradlew spotlessCheck 通过;run.halo.app.core.attachment.*
    run.halo.app.infra.* 包全量测试通过。
  • 说明:完整后端测试套件中 CategoryFinderImplTest.listAsTreeTreatsInvalidParentsAsRoots
    存在一个预先存在的失败(根节点输出顺序为名称字典序,与测试期望的输入顺序不符),
    已在未包含本次修改的基线上复现,与本次 PR 无关。
  • 本 PR 由 AI 辅助生成,代码已经人工审查(This PR was prepared with AI assistance
    and reviewed locally)。

Does this PR introduce a user-facing change?

修复默认存储策略(本地存储)的配置(如"上传界面显示优先级")在重启后被还原的问题

Mark the built-in default-policy as do-not-overwrite so that user
modifications such as the upload display priority label are no longer
reverted by the extension resource initializer on every startup.

Fixes halo-dev#8259
@CLAassistant

CLAassistant commented Aug 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sonarqubecloud

Copy link
Copy Markdown

@ruibaby
ruibaby requested a review from JohnNiang August 18, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

默认存储策略修改“上传界面显示优先级”重启后恢复到默认值

2 participants