diff --git a/sfm/server.py b/sfm/server.py index cd2cf80..a7b8cae 100644 --- a/sfm/server.py +++ b/sfm/server.py @@ -1659,8 +1659,33 @@ async def db_import_blastware_file( continue if name.lower().endswith(".txt"): - # Strip the ".txt" suffix to get the binary's filename. - reports[name[:-4].lower()] = content + # Pair the report back to its binary. BW writes ASCII + # reports under two conventions: + # + # 1. ACH convention (Blastware's official Auto Call Home): + # binary: M529LK44.AB0 + # report: M529LK44_AB0_ASCII.TXT + # (replaces the "." with "_", appends "_ASCII.TXT") + # + # 2. Manual-export convention (operator clicks Save As Text + # in BW's UI): + # binary: M529LK44.AB0 + # report: M529LK44.AB0.TXT + # (literal binary filename + ".TXT" suffix) + # + # We register BOTH possible binary names as keys so the + # subsequent lookup matches whichever convention was used. + stripped = name[:-4] # remove ".TXT" + # ACH convention: strip "_ASCII" and convert the last "_" + # back to "." to recover the binary's filename. + if stripped.lower().endswith("_ascii"): + inner = stripped[:-6] # remove "_ASCII" + under = inner.rfind("_") + if under >= 0: + ach_binary = inner[:under] + "." + inner[under + 1 :] + reports[ach_binary.lower()] = content + # Legacy convention: the stripped name IS the binary's name. + reports[stripped.lower()] = content else: binaries.append((name, content))