fix(voice): cascade delete, rename, and move folder operations to descendants #16
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_voice!16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_delete_folder_recursive"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes three related bugs in
VoiceServicefolder operations where mutations to a folder were not propagated to its descendants.delete_folderonly removed the folder's own DB row. Child topics, sub-folders, and their on-disk audio/transform files stayed behind as orphans.rename_folderupdated only the target folder'sname. Descendants'parent_pathkept pointing at the old path, making them unreachable from the tree.move_folderupdated only the target folder'sparent_path. Same descendants-go-stale problem, and nothing stopped a move into the folder's own subtree (which would create a cycle).Related Issue
Closes #12
Changes
All in
crates/hero_voice/src/voice/server/rpc.rs. No UI, SDK, schema, or generated-code touches.folder_full_path(&Folder) -> String— one place for theparent_path + "/" + nameconvention used by the UI's tree builder.rewrite_path(path, old_prefix, new_prefix) -> Option<String>— returns a rewritten path iff the input starts withold_prefixas a whole path segment (exact match or followed by/). Avoids thestarts_withfootgun where"work"would wrongly match"work_backup".const MAX_FOLDER_DEPTH: usize = 64— depth budget for cycle protection.delete_folderto cascade:NotFoundfor unknown sids).delete_topicso audio-dir and transforms-dir cleanup stays in one place.delete_folder_children(snapshot-then-iterate, depth-budgeted).rename_folderto capture old/new full path, persist the renamed folder, then cascade the path change to every descendant.move_folderto capture old full path, reject self/descendant destinations withInvalidInput(tree-cycle guard), persist, then cascade.VoiceServiceHandler::propagate_path_change(old_prefix, new_prefix)used by bothrename_folderandmove_folder.Test Results
Command:
cargo test -p hero_voice --features voiceTwo new integration tests:
delete_folder_cascades— covers empty folder, folder with one topic (DB + fs verification), nested sub-tree, and sibling isolation.rename_and_move_folder_cascades— covers rename propagation through two nesting levels, sibling isolation against prefix-only matches, move propagation for a mid-tree folder, and rejection of moves into self or descendants.Both tests share a module-level
Mutexto serialisestd::env::set_current_dir(needed becauserpc.rsstill uses the relativeDATA_DIR = "data"path).cargo clippy -p hero_voice --features voice --all-targets -- -D warningspasses.c480a70897107f6103a7