feat: move index storage from XDG_CACHE_HOME to XDG_DATA_HOME#211
feat: move index storage from XDG_CACHE_HOME to XDG_DATA_HOME#211deepin-bot[bot] merged 3 commits intolinuxdeepin:develop/snipefrom
Conversation
Added comprehensive image format support to the indexer by analyzing Qt5 imageformat plugins. Extended pic_file_suffix field to include modern formats (AVIF, HEIF, WebP), professional formats (EXR, EPS, PSD), KDE/Krita formats (KRA, ORA), SGI legacy formats (RGB, SGI, BW), and major camera RAW formats (CR2, NEF, DNG, ARW, etc.). Influence: 1. Test index creation with new image formats - verify correct recognition 2. Test search functionality - verify new formats appear in image category 3. Verify backward compatibility - existing indexes continue to work 4. Test RAW format indexing on various camera files Log: Extend image format support for Qt5 compatible formats feat: 基于 Qt5 插件扩展图片格式支持 通过分析 Qt5 imageformat 插件,为索引器添加了全面的图片格式支持。 扩展 pic_file_suffix 字段,新增现代格式 (AVIF, HEIF, WebP)、专业格式 (EXR, EPS, PSD)、 KDE/Krita 格式 (KRA, ORA)、SGI 遗留格式 (RGB, SGI, BW) 以及主流相机 RAW 格式 (CR2, NEF, DNG, ARW 等)。 Influence: 1. 测试新图片格式的索引创建 - 验证正确识别 2. 测试搜索功能 - 验证新格式出现在图片类别中 3. 验证向后兼容性 - 现有索引继续工作 4. 测试各种相机文件的 RAW 格式索引 Log: 扩展图片格式支持以兼容 Qt5 格式
Changed the index storage location from XDG_CACHE_HOME to XDG_DATA_HOME to ensure the index data survives cache cleaning operations. Added a migration function that automatically moves existing index data from the old location to the new one on first run. Influence: 1. Test fresh installation - verify index created in ~/.local/share 2. Test upgrade scenario - verify migration from ~/.cache to ~/.local/share 3. Test migration with large index - verify performance and correctness 4. Test cross-device migration - verify fallback copy+remove works 5. Verify old directory cleanup after successful migration Log: Migrate index storage to the XDG_DATA_HOME directory feat: 将索引存储从 XDG_CACHE_HOME 迁移至 XDG_DATA_HOME 将索引存储位置从 XDG_CACHE_HOME 更改为 XDG_DATA_HOME,确保索引数据不会被 缓存清理工具删除。新增迁移函数,在首次运行时自动将现有索引数据从旧位置 移动到新位置。 Influence: 1. 测试全新安装 - 验证索引在 ~/.local/share 中创建 2. 测试升级场景 - 验证从 ~/.cache 迁移至 ~/.local/share 3. 测试大索引迁移 - 验证性能和正确性 4. 测试跨设备迁移 - 验证 copy+remove 回退方案 5. 验证迁移成功后旧目录已清理 Log: 将索引存储迁移至 XDG_DATA_HOME 目录
Reviewer's GuideMoves the persistent index storage directory from XDG_CACHE_HOME to XDG_DATA_HOME, adds an on-start migration path for existing indexes, and adjusts running-flag handling to be idempotent and resilient to index directory deletion. Sequence diagram for daemon startup with index migration and running flagsequenceDiagram
participant DaemonMain
participant Config
participant FileSystem
participant Logger
participant RunningFlag
DaemonMain->>Config: make_event_handler_config()
activate Config
Config->>FileSystem: get_user_cache_dir()
Config->>FileSystem: get_user_data_dir()
Config->>Config: migrate_index_dir(old_index_dir, new_index_dir)
activate Config
Config->>FileSystem: exists(new_index_dir)
alt new_index_dir exists
Config-->>Config: return (no migration)
else new_index_dir does not exist
Config->>FileSystem: exists(old_index_dir)
alt old_index_dir does not exist
Config-->>Config: return (no migration)
else old_index_dir exists
Config->>Logger: info(migrating index)
Config->>FileSystem: create_directories(parent_path)
alt error creating parent
Config->>Logger: error(failed to create parent)
Config-->>Config: return
else parent created
Config->>FileSystem: rename(old_index_dir, new_index_dir)
alt rename succeeds
Config->>Logger: info(migration completed)
else rename fails
Config->>Logger: error(rename failed)
Config->>FileSystem: copy(old_index_dir, new_index_dir, recursive)
alt copy fails
Config->>Logger: error(copy failed)
Config-->>Config: return
else copy succeeds
Config->>FileSystem: remove_all(old_index_dir)
alt remove_all fails
Config->>Logger: warn(remove old dir failed)
end
Config->>Logger: info(migration completed)
end
end
end
end
end
deactivate Config
Config-->>DaemonMain: event_handler_config with persistent_index_dir=new_index_dir
deactivate Config
DaemonMain->>RunningFlag: set_running_flag()
activate RunningFlag
RunningFlag->>FileSystem: get_running_flag_path()
RunningFlag->>FileSystem: file_exists(running_flag_path)
alt running flag exists
RunningFlag->>Logger: debug(flag exists, skipping)
RunningFlag-->>DaemonMain: return
else running flag missing
RunningFlag->>FileSystem: write_file(running_flag_path)
alt write fails
RunningFlag->>Logger: warn(failed to set running flag)
end
RunningFlag-->>DaemonMain: return
end
deactivate RunningFlag
DaemonMain->>DaemonMain: start event listener with handler
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
migrate_index_dir, consider only switchingconfig.persistent_index_dirtonew_index_dirwhen the migration actually succeeds; as written, a failed rename/copy will still point the config to an empty new directory and effectively drop the existing index. - The error handling in
migrate_index_dircould be more robust by checking and loggingstd::filesystem::existsfailures (whenecis set) instead of silently returning, so permission or I/O issues during migration are visible. - Re-running
set_running_flag()inmainto handle a removed index dir is somewhat implicit; consider encapsulating this logic insideset_running_flagor documenting the dependency so future changes to the running flag behavior don’t accidentally break this guarantee.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `migrate_index_dir`, consider only switching `config.persistent_index_dir` to `new_index_dir` when the migration actually succeeds; as written, a failed rename/copy will still point the config to an empty new directory and effectively drop the existing index.
- The error handling in `migrate_index_dir` could be more robust by checking and logging `std::filesystem::exists` failures (when `ec` is set) instead of silently returning, so permission or I/O issues during migration are visible.
- Re-running `set_running_flag()` in `main` to handle a removed index dir is somewhat implicit; consider encapsulating this logic inside `set_running_flag` or documenting the dependency so future changes to the running flag behavior don’t accidentally break this guarantee.
## Individual Comments
### Comment 1
<location path="src/daemon/src/main.cpp" line_range="106-107" />
<code_context>
event_listenser listenser;
print_event_handler_config(event_handler_config);
default_event_handler handler(event_handler_config);
+ // Set running flag again for index dir may removed
+ set_running_flag();
listenser.set_handler([&handler](fs_event *event) {
handler.handle(event);
</code_context>
<issue_to_address>
**suggestion:** Clarify the relationship between the running flag and index directory removal, and whether the second call is needed.
Right now it’s unclear why this second `set_running_flag()` depends on potential index directory removal, especially since `set_running_flag()` no-ops if the flag already exists. If the flag lives under the migrated index directory, consider creating it as part of the directory migration/initialization instead of re-calling it here, or document this coupling so future index layout changes don’t unintentionally break the running-flag behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Make set_running_flag() idempotent by checking if the flag file already exists before attempting to create it. Also re-call set_running_flag() in main after handler setup to handle cases where the index directory may have been removed externally. Influence: 1. Test daemon startup - verify running flag created once 2. Test repeated set_running_flag calls - verify no duplicate operations 3. Test with index dir removed externally - verify flag re-created Log: Optimize running flag setup with idempotent check fix: 为运行标志设置添加幂等检查并支持重复调用 使 set_running_flag() 具有幂等性,在创建标志文件前先检查是否已存在。同时 在 main 中 handler 设置后重新调用 set_running_flag(),以处理索引目录可能 被外部删除的情况。 Influence: 1. 测试守护进程启动 - 验证运行标志仅创建一次 2. 测试重复调用 set_running_flag - 验证无重复操作 3. 测试索引目录被外部删除 - 验证标志能重新创建 Log: 优化运行标志设置逻辑并添加幂等检查
deepin pr auto review这份代码变更主要涉及将索引数据存储位置从缓存目录迁移到数据目录,并增加了对更多图片格式的支持。以下是对代码的详细审查意见: 1. 语法与逻辑config.cpp 中的
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wangrong1069 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 |
|
/merge |
Summary by Sourcery
Migrate persistent index storage to XDG data directory and improve process running-flag handling.
New Features:
Enhancements: