Skip to content

Cache friendly name by UDID rather than globally#96

Merged
grahamgilbert merged 2 commits intosalopensource:mainfrom
thehilll:cache-model-by-udid
Aug 4, 2021
Merged

Cache friendly name by UDID rather than globally#96
grahamgilbert merged 2 commits intosalopensource:mainfrom
thehilll:cache-model-by-udid

Conversation

@thehilll
Copy link
Copy Markdown
Contributor

Create a directory for caching machine friendly name, within that store name in .txt file. Cleans out any file not for the current UDID.

This addresses the situation where the global cache file is migrated via Migration Assistant and Sal reports the old machine friendly name.

Create a directory for caching machine friendly name, within that store name in <UDID>.txt file.  Cleans out any file not for the current UDID.

This addresses the situation where the global cache file is migrated via Migration Assistant and Sal reports the old machine friendly name.
for cache_file in MODEL_PATH.iterdir():
# clean up any other files in dir
if cache_file != UDID_CACHE_PATH:
cache_file.unlink()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably handle failing to remove the file for whatever reason

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, no reason to kill the whole thing for something that is just housekeeping. I added

# clean up any other files in dir
        if cache_file != UDID_CACHE_PATH:
            try:
                cache_file.unlink()
            except:
                pass

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just wanted to follow up and see if you think this is a good way to handle failure to remove that file.

Use a try/except to avoid killing the whole process if an unused cache file can't be removed
@grahamgilbert grahamgilbert merged commit 6dda3ee into salopensource:main Aug 4, 2021
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.

2 participants