From c9b6e8bb1c5432c0bf432f520fbce3e2564e41c9 Mon Sep 17 00:00:00 2001 From: zanllp Date: Sun, 14 Apr 2024 06:34:50 +0800 Subject: [PATCH] fix --- migrate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migrate.py b/migrate.py index b1b3380..8bf0926 100644 --- a/migrate.py +++ b/migrate.py @@ -27,7 +27,7 @@ def replace_path(old_base, new_base): return replace_func -def update_paths(conn, table_name): +def update_paths(conn, table_name, old_base): """ Update paths in a specified SQLite table using a custom SQL function. @@ -54,7 +54,7 @@ def setup_parser() -> argparse.ArgumentParser: description="Script to migrate paths in an IIB SQLite database from an old directory structure to a new one." ) parser.add_argument( - "--db_path", type=str, help="Path to the input IIB QLite database file to be migrated. Default value is 'iib.db'.", required=True, default="iib.db" + "--db_path", type=str, help="Path to the input IIB QLite database file to be migrated. Default value is 'iib.db'.", default="iib.db" ) parser.add_argument( "--old_dir", type=str, help="Old base directory to be replaced in the paths.", required=True @@ -76,9 +76,9 @@ if __name__ == "__main__": DataBase.path = os.path.normpath(os.path.join(os.getcwd(), db_temp_path)) conn = DataBase.get_conn() conn.create_function("replace_path", 1, replace_path(old_base, new_base)) - update_paths(conn, "image") - update_paths(conn, "extra_path") - update_paths(conn, "folders") + update_paths(conn, "image", old_base) + update_paths(conn, "extra_path", old_base) + update_paths(conn, "folders", old_base) shutil.copy(db_temp_path, "iib.db") # os.remove(db_temp_path) print("Database migration completed successfully.")