-
Notifications
You must be signed in to change notification settings - Fork 275
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
ngclient: experiment with separating local target caching from updater #1412
Comments
I'll just document this other idea wrt client cache here: Using unrestricted external input as filenames is a bad idea (even if the input is from signed metadata), but the updater does this with targetpaths as local filepaths: Luckily there is nothing requiring client target cache to use targetpaths as local filesystem paths:
|
One feature we have not carried over from old updater is
All that said, the functionality sounds very application specific and I doubt we should spend time on this for ngclient itself |
Ok, I've played with this quite a bit and have changed my mind a little:
Possibly it makes sense to close this issue and continue a in a new one as the title and description are not descriptive but I will lay out my current experiment here:
This leads to minimal complete example: updater = Updater(local_metadata, metadata_url, targets_url)
info = updater.get_targetinfo("file.txt")
path = updater.get_local_target(info, "~/downloads/")
if path is None:
path = updater.download_target(info, "~/downloads/") I'm not sure if the method names are the best but I think the arguments and return values make a lot of sense, and make the API easier to understand. One change I might still make is the "negative result" in get_local_target(): if it raised instead of returning None, the local and remote target getters would have practically identical signatures... |
Closing this as the work continues in #1580. |
This comes from #1317
I'm seriously considering if Updater on its own should not support local target caching at all -- it's not part of the spec, it has these sharp corners WRT urls being used as file paths, and I think it could be handled as well by an external component like a derived class (that we may or may not want to provide).
People, me included, keep getting confused about what targetpaths are: it should be clear that they are just url-fragments that serve two purposes:
but currently the client implementation uses targetpath also as a local filesystem path. Spec does not demand using the path (it does sort of say files should be saved with the same filename that was used in URL however -- this is likely spec overreach). Separating the caching so that a spec compliant updater can be implemented without all the filesystem path issues would make it clearer what targetpaths are.
Non-caching updater could look like
The CachingUpdater would add:
The text was updated successfully, but these errors were encountered: