-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
b0e7dd4
to
37f329f
Compare
37f329f
to
49faa20
Compare
There was a problem hiding this 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(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
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.
Line 66 in 473045f
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.
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