feat(cogify): ensure cogify path-like args have trailing slashes. BM-858 #2903
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What does this change aim to achieve?
Updates the cogify CLI commands to ensure that arguments representing folder paths have trailing slashes. Adds a
UrlFolder
parser for cmd-ts which parses the input string as a URL, and appends a trailing slash if it's missing. Changing the type fromstring
toURL
(via theUrl
or newUrlFolder
parsers) involved changing places that use these values to construct other paths. Where these are passed tofsa
functions, these are converted back to strings usingurlToString
.Intention
Why is this change being made? What implications or other considerations are there?
Parts of the cogify commands were using strings for paths, while other parts were using URLs. This led to a situation where a string path was created by
fsa.joinAll()
which did not have a trailing slash, which was then passed to the URL constructor, resulting in a URL one directory higher than intended being created, which prevented finding the STAC collection.json file.The calls to
urlToString
will be unnecessary once we upgrade to chunkd v11 which swaps to receiving URLs directly, however that is a much larger piece of work so for the time being we'll continue to gradually migrate to using URLs and useurlToString
as needed when passing values tofsa
functions.Checklist
If not applicable, provide explanation of why.