feat(media): global asset library backend storage (#54)#104
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
COME REVIEW!!! |
appergb
approved these changes
Jun 23, 2026
appergb
left a comment
Owner
There was a problem hiding this comment.
审核通过 ✅(自动审核流程)
- 独立新文件
crates/opentake-media/src/library.rs,不碰既有 media.rs/MediaPanel,与 #91 重写计划无重叠。 - CI 双绿(Rust fmt/clippy/test + Web build);本地复核 cargo check/fmt/clippy 干净、214 测试全过(含 9 个 library 测试)。
- issue #54 三项验收(copy-on-favorite+manifest 写入、SHA-256 内容寻址去重、原子写 .tmp rename + Mutex 并发安全)均有测试覆盖。
- 路径安全(id 为 SHA-256 hex、ext 经 Path::extension() 提取,无遍历)。无硬编码密钥。
- 上游 palmier-pro 无全局库模块,#37 为 OpenTake 新增子系统,无 1:1 要求。
合并后 #106 将自动 retarget 到 main。
@Felix201209 一个 follow-up(非阻塞):library.rs:322 remove() 用 let _ = std::fs::remove_file(path) 静默吞错,建议在 #106 命令层合并前补一行 tracing::warn! 记录删除失败,避免 manifest 与磁盘状态不一致时无日志可查。
4 tasks
This was referenced Jun 23, 2026
H-Chris233
pushed a commit
to H-Chris233/OpenTake
that referenced
this pull request
Jun 24, 2026
…ged; clarify appergb#37 vs appergb#91 scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
实现简述
新增
crates/opentake-media/src/library.rs:全局可复用素材库的后端存储层(#37 的后端打底,#37-B/#37-C 依赖)。LibraryStore:以显式根目录构造(便于测试 + 由 [#37-B] 全局库 Tauri 命令层(list/favorite/categorize/rename/delete/import_to_project) #55 命令层从 Tauriapp_data_dir传入),内部含Mutex串行化清单读改写。default_library_dir():用dirscrate 跨平台解析<data dir>/OpenTake/Library(macOS 即~/Library/Application Support/OpenTake/Library/)。library.json清单:{ version, entries: [...] },条目LibraryEntry { id, type, category, favoritedAt, source, thumb },serde camelCase +type重命名 + 每字段#[serde(default)]容旧。Mutex防并发收藏互相覆盖。lib.rs仅追加一行pub mod library;;Cargo.toml新增dirs = "6"。逐条对照 #54 验收
favorite_copies_file_and_writes_manifest验证files/<hash><ext>落盘 +library.json写入 + 重载一致。dedup_same_content_does_not_duplicate:两个不同源路径、相同字节 → 同一 id、清单 1 条、库内 1 文件。std::fs::rename原子覆盖;Mutex串行化读改写。cargo test:copy-on-favorite、去重、分类过滤 — 10 个单测覆盖收藏复制、去重、entries_in_category分类过滤(Some(c)/None分区)、移除、serde 全字段 roundtrip、camelCase JSON。fmt+clippy绿。测试结果
cargo fmt --all:无改动。cargo clippy -p opentake-media --all-targets -- -D warnings:绿。cargo test -p opentake-media:214 passed + 10 new(library)passed, 0 failed。Closes #54