added handling for FCCS stripping . out of drawer names

This commit is contained in:
2026-08-18 15:34:17 -05:00
parent ca2c49019f
commit 8a6083e177
2 changed files with 29 additions and 4 deletions

View File

@@ -86,11 +86,23 @@ def main():
# (e.g. the Restore directory) there are also system folders that start with
# "$" and miscellaneous loose files — skip both. The isdir check drops the
# files; the "$" prefix check drops the system folders.
drawer_ids = sorted(
raw_dirs = [
name for name in os.listdir(backup_dir)
if not name.startswith("$")
and os.path.isdir(os.path.join(backup_dir, name))
)
]
# FileCabinet CS ignores "." in drawer IDs: a folder named "A123.TJ" on disk
# is searched and displayed in the UI as "A123TJ", so searching the dotted
# form returns nothing. Everything downstream uses the UI form — export types
# the ID into the search box, and FCCS embeds the same dot-free ID as the
# prefix of exported filenames (which manifest names and verify/report keys
# are matched against) — so normalize by stripping dots here at the source.
normalized = {}
for name in raw_dirs:
did = name.replace(".", "")
normalized.setdefault(did, []).append(name)
drawer_ids = sorted(normalized)
with open(output_file, "w", encoding="utf-8") as f:
for did in drawer_ids:
@@ -98,6 +110,17 @@ def main():
log(f"Found {len(drawer_ids)} drawers, written to {output_file}")
# Warn if stripping dots collapsed two distinct folders onto one FCCS ID —
# that would silently drop a drawer from the inventory otherwise.
collisions = {did: names for did, names in normalized.items() if len(names) > 1}
if collisions:
log("-" * 60)
log(f"WARNING: {len(collisions)} drawer ID(s) collide after removing "
"'.' — multiple folders map to a single FCCS ID:")
for did, names in sorted(collisions.items()):
log(f" {did} <- {', '.join(sorted(names))}")
log("-" * 60)
# Flag prefix clashes: FCCS search on the shorter ID pops a selection box.
clashes = check_for_clashes(drawer_ids)
if clashes: