Enhance slug deduplication and metadata handling in syncback process

- Introduced a new method `dedup_against_dir` to deduplicate slugified names against existing entries in a parent directory, improving collision handling during file operations.
- Updated the `syncback_added_instance` method to utilize sibling slug sets, ensuring new instances do not overwrite existing files or directories.
- Refactored `strip_middleware_extension` to be publicly accessible for broader use in deduplication logic.
- Improved comments and code organization for better clarity in the slugification and deduplication processes.
This commit is contained in:
Joe 2026-02-10 18:09:53 -06:00
parent f38c1f1311
commit 7d47fe73f6
4 changed files with 238 additions and 53 deletions

View file

@ -85,8 +85,9 @@ pub fn name_for_inst<'a>(
}
/// Strips the middleware extension from a filename to recover the bare slug.
/// Used internally by `name_for_inst` to derive the dedup key for old instances.
fn strip_middleware_extension(filename: &str, middleware: Middleware) -> String {
/// Used by `name_for_inst` to derive the dedup key for old instances, and by
/// callers that need to seed `taken_names` from filesystem paths.
pub fn strip_middleware_extension(filename: &str, middleware: Middleware) -> String {
// Dir middleware has no extension — filename IS the slug
match middleware {
Middleware::Dir

View file

@ -31,7 +31,7 @@ use crate::{
pub use file_names::{
deduplicate_name, extension_for_middleware, name_for_inst, name_needs_slugify, slugify_name,
validate_file_name,
strip_middleware_extension, validate_file_name,
};
pub use fs_snapshot::FsSnapshot;
pub use hash::*;