Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix backup freeze bug #82

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wikitextprocessor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def backup_db_path(self) -> Path:

def backup_db(self) -> None:
self.backup_db_path.unlink(True)
self.db_conn.commit()
backup_conn = sqlite3.connect(self.backup_db_path)
with backup_conn:
self.db_conn.backup(backup_conn)
Expand Down
10 changes: 6 additions & 4 deletions wikitextprocessor/dumpparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,24 @@ def _add_page_wrapper(
if save_pages_path is not None:
save_pages_to_file(ctx, save_pages_path)

analyze_and_overwrite_pages(ctx, overwrite_folders)
analyze_and_overwrite_pages(ctx, overwrite_folders, skip_extract_dump)


def analyze_and_overwrite_pages(
ctx: "Wtp", overwrite_folders: Optional[List[Path]]
ctx: "Wtp", overwrite_folders: Optional[List[Path]], skip_extract_dump: bool
) -> None:
if overwrite_folders is not None:
if overwrite_pages(ctx, overwrite_folders, False):
# has template
ctx.backup_db()
if skip_extract_dump:
ctx.backup_db()
overwrite_pages(ctx, overwrite_folders, True)
ctx.analyze_templates()
else:
if not ctx.has_analyzed_templates():
ctx.analyze_templates()
ctx.backup_db()
if skip_extract_dump:
ctx.backup_db()
overwrite_pages(ctx, overwrite_folders, True)
elif not ctx.has_analyzed_templates():
ctx.analyze_templates()
Expand Down