From 5b3312b43cc8bbee039cf61407e021ec73da395d Mon Sep 17 00:00:00 2001 From: wangrong Date: Fri, 17 Apr 2026 14:26:51 +0800 Subject: [PATCH 1/3] feat: extend image format support based on Qt5 plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 格式 --- .gitignore | 1 + assets/org.deepin.anything.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5817128..5015b51 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,7 @@ debian/deepin-anything-server.debhelper.log .cursor/ .specstory/ .cursorindexingignore +.claude/ # kernelmod src/kernelmod/.Module.symvers.cmd diff --git a/assets/org.deepin.anything.json b/assets/org.deepin.anything.json index 652e35d..b81e78c 100644 --- a/assets/org.deepin.anything.json +++ b/assets/org.deepin.anything.json @@ -69,7 +69,7 @@ "visibility": "public" }, "pic_file_suffix": { - "value": "ani;bmp;gif;ico;jpe;jpeg;jpg;pcx;png;psd;tga;tif;tiff;webp;wmf;svg", + "value": "ani;avif;avifs;bmp;bw;dci;eps;epsf;epsi;exr;gif;heic;heif;heis;heix;icns;ico;jpe;jpeg;jpg;kra;mng;ora;pcx;pic;png;psd;raf;ras;raw;rgb;rgba;sgi;svg;svgz;tga;tif;tiff;wbmp;webp;wmf;xcf;cr2;crw;nef;dng;arw;orf;rw2;pef;srw;mrw;x3f;dcr;kdc;3fr;nrw;mef;iiq;sr2;erf;mos;rwl", "serial": 0, "flags":[], "name": "Pic File Suffix", From 086a762b502846534bafc0bbac8fe67f188a6435 Mon Sep 17 00:00:00 2001 From: wangrong Date: Fri, 17 Apr 2026 14:45:12 +0800 Subject: [PATCH 2/3] feat: move index storage from XDG_CACHE_HOME to XDG_DATA_HOME MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 目录 --- src/daemon/src/core/config.cpp | 58 +++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/daemon/src/core/config.cpp b/src/daemon/src/core/config.cpp index 29e841b..17086ee 100755 --- a/src/daemon/src/core/config.cpp +++ b/src/daemon/src/core/config.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #define COMMIT_VOLATILE_INDEX_TIMEOUT_DEFAULT 2 #define COMMIT_VOLATILE_INDEX_TIMEOUT_MIN 1 @@ -252,10 +253,65 @@ Config::~Config() { g_object_unref(dbus_connection_); } +static void migrate_index_dir(const std::string& old_dir, const std::string& new_dir) { + std::error_code ec; + + // Skip if new directory already exists + if (std::filesystem::exists(new_dir, ec)) { + return; + } + + // Skip if old directory doesn't exist + if (!std::filesystem::exists(old_dir, ec)) { + return; + } + + spdlog::info("Migrating index from {} to {}", old_dir, new_dir); + + // Create parent directory for new location + auto parent_path = std::filesystem::path(new_dir).parent_path(); + if (!std::filesystem::exists(parent_path, ec)) { + std::filesystem::create_directories(parent_path, ec); + if (ec) { + spdlog::error("Failed to create parent directory {}: {}", parent_path.string(), ec.message()); + return; + } + } + + // Move the directory + std::filesystem::rename(old_dir, new_dir, ec); + if (ec) { + spdlog::error("Failed to migrate index directory: {}", ec.message()); + // If rename fails (e.g., cross-device), try copy and remove + ec.clear(); + std::filesystem::copy(old_dir, new_dir, std::filesystem::copy_options::recursive, ec); + if (ec) { + spdlog::error("Failed to copy index directory: {}", ec.message()); + return; + } + ec.clear(); + std::filesystem::remove_all(old_dir, ec); + if (ec) { + spdlog::warn("Failed to remove old index directory: {}", ec.message()); + } + } + + spdlog::info("Index migration completed successfully"); +} + event_handler_config Config::make_event_handler_config() { event_handler_config config; - config.persistent_index_dir = std::string(g_get_user_cache_dir()) + "/deepin-anything-server"; + + // Use XDG_DATA_HOME for persistent index storage (instead of XDG_CACHE_HOME) + // This ensures the index survives cache cleaning operations + std::string old_index_dir = std::string(g_get_user_cache_dir()) + "/deepin-anything-server"; + std::string new_index_dir = std::string(g_get_user_data_dir()) + "/deepin-anything-server"; + + // Migrate from old location to new location if needed + migrate_index_dir(old_index_dir, new_index_dir); + + config.persistent_index_dir = new_index_dir; config.volatile_index_dir = config.persistent_index_dir; config.blacklist_paths = blacklist_paths_; config.indexing_paths = indexing_paths_; From 025de5018aaeedfaa68925512707bf9c03677081 Mon Sep 17 00:00:00 2001 From: wangrong Date: Fri, 17 Apr 2026 15:27:08 +0800 Subject: [PATCH 3/3] fix: add idempotent check and re-call for running flag setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 优化运行标志设置逻辑并添加幂等检查 --- src/daemon/src/main.cpp | 2 ++ src/daemon/src/utils/running_flag.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/daemon/src/main.cpp b/src/daemon/src/main.cpp index a8427ee..bd84c5b 100644 --- a/src/daemon/src/main.cpp +++ b/src/daemon/src/main.cpp @@ -103,6 +103,8 @@ int main(int argc, char* argv[]) { event_listenser listenser; print_event_handler_config(event_handler_config); default_event_handler handler(event_handler_config); + // default_event_handler 实例化时, 可能会清空索引目录, 这里重新设置 running 标志 + set_running_flag(); listenser.set_handler([&handler](fs_event *event) { handler.handle(event); }); diff --git a/src/daemon/src/utils/running_flag.cpp b/src/daemon/src/utils/running_flag.cpp index 0e29a9b..43d2eed 100755 --- a/src/daemon/src/utils/running_flag.cpp +++ b/src/daemon/src/utils/running_flag.cpp @@ -96,6 +96,11 @@ void set_running_flag(void) std::string running_flag_path = get_running_flag_path(); + if (g_file_test(running_flag_path.c_str(), G_FILE_TEST_EXISTS)) { + spdlog::debug("Running flag already exists at {}, skipping", running_flag_path); + return; + } + if (!g_file_set_contents(running_flag_path.c_str(), "", -1, nullptr)) { spdlog::warn("Failed to set running flag at {}: {}", running_flag_path, strerror(errno));