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

removes old archives from client cache dir #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JessicaTegner
Copy link
Contributor

This loops through all files in "self.current_archive_local_path.parent" and deletes all files that are not equal to "self.current_archive_local_path".
Fixes #92

@JessicaTegner JessicaTegner force-pushed the issue92 branch 6 times, most recently from b0e7dd4 to 37f329f Compare October 11, 2024 20:00
Copy link
Owner

@dennisvang dennisvang left a comment

Choose a reason for hiding this comment

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

Thanks again. :)
The location looks good, but implementation does need a bit of work imho.
See comments.

@@ -184,6 +184,13 @@ def check_for_updates(
sys.exit()
return None
# check for new target files (archives and patches)
# look through all files in self.current_archive_local_path.parent, and remove all that is not self.current_archive_local_path
# this is to save space
for file in self.current_archive_local_path.parent.iterdir():
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
for file in self.current_archive_local_path.parent.iterdir():
for path in self.current_archive_local_path.parent.iterdir():

for consistency

for file in self.current_archive_local_path.parent.iterdir():
metadata_for_file = TargetMeta.parse_filename(file.name)
logger.debug(f'checking {metadata_for_file}')
if TargetMeta(name=metadata_for_file["name"], version=metadata_for_file["version"], is_archive=metadata_for_file["suffix"]) < self.current_archive:
Copy link
Owner

Choose a reason for hiding this comment

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

TargetMeta can be instantiated directly from the file path, so no need for the parse_filename() call.

Initialize either with target_path, or with name, version, archive.

To be safe, I would remove any and all .patch files and .tar.gz files not equal to current_archive.

It would be nice if this could be placed in a separate method, e.g. clean_cache(), which is then called from here.

The clean_cache() method would need a test as well.

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.

remove old archives from client cache dir
2 participants