Skip to content

Remove diff files#176

Merged
wonder-sk merged 9 commits intomasterfrom
remove_diff_files
Jul 17, 2023
Merged

Remove diff files#176
wonder-sk merged 9 commits intomasterfrom
remove_diff_files

Conversation

@JanCaha
Copy link
Copy Markdown
Contributor

@JanCaha JanCaha commented Jun 28, 2023

In MerginProject method get_push_changes() check for zero size diff files and removes them.

In MerginClient method push_project() clean any existing diff files when the method ends.

Fixes #47

@JanCaha JanCaha requested a review from wonder-sk June 28, 2023 09:11
"size": diff_size,
"mtime": datetime.fromtimestamp(os.path.getmtime(diff_file), tzlocal()),
}
if diff_size > 0:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if diff_size > 0" is not necessary, because the self.geodiff.has_changes(diff_file) check above is equivalent of that

mergin/client.py Outdated
return # there is nothing to push (or we only deleted some files)
push_project_wait(job)
push_project_finalize(job)
self.clean_temp_files(directory)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to clean temp files in the push_project_finalize() call instead of here...

mergin/client.py Outdated
mergin_dir = Path(directory) / ".mergin"
if mergin_dir.exists():
for file in mergin_dir.glob("*-diff-*"):
file.unlink()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than doing this kind of bulk erase, I would prefer that after the call to get_push_changes(), we figure out list of all temporary diff files (using changes["updated"] entries that have "diff" key - as created in get_push_changes().

@JanCaha
Copy link
Copy Markdown
Contributor Author

JanCaha commented Jun 28, 2023

The clean in push_project_finalize() should also happen in cases when errors are raised, right? So that the diff files removed in any case.

@JanCaha
Copy link
Copy Markdown
Contributor Author

JanCaha commented Jul 13, 2023

Fixes #47

@wonder-sk wonder-sk merged commit d441cf2 into master Jul 17, 2023
@MarcelGeo MarcelGeo deleted the remove_diff_files branch September 4, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up of temp files after sync

2 participants