feat: implement app icon management and caching mechanism#11719
feat: implement app icon management and caching mechanism#11719zhengkunwang223 merged 3 commits into1Panel-dev:dev-v2from
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
- Refactored app synchronization tasks to improve structure and clarity. - Introduced shared context for managing app sync state and metadata. - Updated icon handling to ensure proper content type and caching. - Adjusted cache control settings for app icons to extend cache duration. - Improved error handling and logging during app sync processes.
…eturn - Removed the fileName return value from GetAppIcon function as it was not utilized. - Enhanced the GetAppIcon method in BaseApi to improve clarity and maintainability. - Ensured proper caching headers are set for app icons.
…#11719) * feat: implement app icon management and caching mechanism * feat: enhance app synchronization and icon management - Refactored app synchronization tasks to improve structure and clarity. - Introduced shared context for managing app sync state and metadata. - Updated icon handling to ensure proper content type and caching. - Adjusted cache control settings for app icons to extend cache duration. - Improved error handling and logging during app sync processes. * refactor: streamline app icon retrieval by removing unused fileName return - Removed the fileName return value from GetAppIcon function as it was not utilized. - Enhanced the GetAppIcon method in BaseApi to improve clarity and maintainability. - Ensured proper caching headers are set for app icons.
What this PR does / why we need it?
#11697
已完成测试,对远端同步改动较大,合并需要慎重考虑对其他情景整体流程无误再合并!
Summary of your change
更改图标存储位置,数据库不再存图标b64,只存图标文件名+etag。
支持 etag 更新
做了向下兼容,base64图标读取仍然可用
流程图 By AI
flowchart TD Start([开始: SyncAppListFromRemote]) --> CheckCustomApp{是否使用<br/>自定义应用?} CheckCustomApp -->|是| ReturnNil1[返回 nil] CheckCustomApp -->|否| CreateTask[创建同步任务] CreateTask --> CheckTaskErr{创建任务<br/>是否成功?} CheckTaskErr -->|失败| ReturnError[返回错误] CheckTaskErr -->|成功| InitSharedCtx[初始化共享上下文] InitSharedCtx --> AddSubTask1[添加子任务1:<br/>基础同步] AddSubTask1 --> AddSubTask2[添加子任务2:<br/>元数据同步] AddSubTask2 --> AsyncExecute[异步执行任务] AsyncExecute --> ReturnNil2[主函数返回 nil] AsyncExecute -.-> SubTask1Start([子任务1: 基础同步]) SubTask1Start --> GetUpdate[检查应用商店更新] GetUpdate --> CheckCanUpdate{可以更新?} CheckCanUpdate -->|否-正在同步| LogSyncing[记录日志并返回] CheckCanUpdate -->|否-已是最新| SetSkipFlag[设置跳过标志] SetSkipFlag --> Task1End[子任务1完成] CheckCanUpdate -->|是| GetAppListData[获取应用列表数据] GetAppListData --> UpdateStatus1[更新状态为同步中] UpdateStatus1 --> InitContext[初始化同步上下文] InitContext --> SyncTags[同步应用标签] SyncTags --> LoadOldApps[加载本地应用] LoadOldApps --> CallGetApps[构建应用映射] CallGetApps --> ClassifyPersist1[分类并持久化应用] ClassifyPersist1 --> UpdateStatusSuccess[更新状态为成功] UpdateStatusSuccess --> AssignSharedCtx[保存共享上下文] AssignSharedCtx --> Task1End Task1End -.-> SubTask2Start([子任务2: 元数据同步]) SubTask2Start --> CheckSharedCtx{共享上下文<br/>是否有效?} CheckSharedCtx -->|否| ReturnNil3[返回 nil] CheckSharedCtx -->|是| CheckSkipFlag{是否跳过<br/>元数据同步?} CheckSkipFlag -->|是| ReturnNil4[返回 nil] CheckSkipFlag -->|否| SyncIconsDetails[同步图标和详情] SyncIconsDetails --> LoopApps[遍历所有应用] LoopApps --> DownloadIcon[下载图标<br/>支持ETag缓存] DownloadIcon --> UpdateDetails[更新应用详情<br/>README/版本等] UpdateDetails --> DownloadCompose[下载docker-compose] DownloadCompose --> ClassifyPersist2[分类并持久化详情] ClassifyPersist2 --> Task2End[子任务2完成] LogSyncing --> Task1End Task2End --> End([结束]) ReturnNil1 --> End ReturnNil2 --> End ReturnNil3 --> End ReturnNil4 --> End ReturnError --> End style Start fill:#2e7d32,stroke:#1b5e20,stroke-width:2px,color:#fff style End fill:#c62828,stroke:#b71c1c,stroke-width:2px,color:#fff style SubTask1Start fill:#1565c0,stroke:#0d47a1,stroke-width:2px,color:#fff style SubTask2Start fill:#ef6c00,stroke:#e65100,stroke-width:2px,color:#fff style AsyncExecute fill:#6a1b9a,stroke:#4a148c,stroke-width:2px,color:#fff style CheckCustomApp fill:#f57f17,stroke:#f57f17,stroke-width:2px,color:#fff style CheckCanUpdate fill:#f57f17,stroke:#f57f17,stroke-width:2px,color:#fff style CheckSharedCtx fill:#f57f17,stroke:#f57f17,stroke-width:2px,color:#fff style CheckSkipFlag fill:#f57f17,stroke:#f57f17,stroke-width:2px,color:#fffPlease indicate you've done the following: