fix(epf-dump): require database connection, remove auto-create empty base

Dump in an empty database irreversibly loses reference types (CatalogRef,
DocumentRef, etc.) — they get converted to xs:string. Instead of silently
creating an empty temp database, the script now exits with an error
explaining that a real database is required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-07 18:34:32 +03:00
co-authored by Claude Opus 4.6
parent f01f9d6ae8
commit 3097811dde
4 changed files with 12 additions and 36 deletions
+4 -16
View File
@@ -58,21 +58,11 @@ def main():
# --- Resolve V8Path ---
v8path = resolve_v8path(args.V8Path)
# --- Auto-create empty database if no connection specified ---
auto_created_base = None
# --- Validate database connection ---
if not args.InfoBasePath and (not args.InfoBaseServer or not args.InfoBaseRef):
auto_base_path = os.path.join(tempfile.gettempdir(), f"epf_dump_db_{random.randint(0, 999999)}")
print("No database specified. Creating temporary empty database...")
print("WARNING: Reference types (CatalogRef, DocumentRef, etc.) will be lost - converted to strings. Use a real database to preserve types.")
result = subprocess.run(
[v8path, "CREATEINFOBASE", f'File={auto_base_path}', "/DisableStartupDialogs"],
capture_output=True, text=True,
)
if result.returncode != 0:
print("Error: failed to create temporary database", file=sys.stderr)
sys.exit(1)
args.InfoBasePath = auto_base_path
auto_created_base = auto_base_path
print("Error: database connection required. Specify -InfoBasePath or -InfoBaseServer/-InfoBaseRef", file=sys.stderr)
print("Dump in an empty database loses reference types (CatalogRef, DocumentRef, etc.) irreversibly.")
sys.exit(1)
# --- Validate input file ---
if not os.path.isfile(args.InputFile):
@@ -140,8 +130,6 @@ def main():
finally:
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir, ignore_errors=True)
if auto_created_base and os.path.exists(auto_created_base):
shutil.rmtree(auto_created_base, ignore_errors=True)
if __name__ == "__main__":