artifactory icon indicating copy to clipboard operation
artifactory copied to clipboard

`path` property of a `GenericRepository` seems to be a malformed `ArtifactoryPath` object

Open briantist opened this issue 1 year ago • 0 comments

The path property of a repository object is an ArtifactioryPath to the repository. The str representation of this object is correct, but it seems like the parts property is missing the repository itself.

This ends up being confusing because while it looks correct as a string or repr, many other methods use the parts, for example if you used this to construct a new ArtifactoryPath.

I will try to demonstrate with some sample code:

ca = ArtifactoryPath('http://localhost:12345/artifactory')
cr = RepositoryLocal(ca, name='abc', package_type=RepositoryLocal.GENERIC)

cr.path
# ArtifactoryPath('http://localhost:12345/artifactory/abc/')

cr.parts
# ('http://localhost:123...rtifactory',)

cr.path.parts
# ('http://localhost:123...rtifactory',)

cp = ArtifactoryPath(cr.path)

cp
# ArtifactoryPath('http://localhost:12345/artifactory')

cp.parts
# ('http://localhost:123...rtifactory',)

cs = cr.path / 'subfolder'

cs
# ArtifactoryPath('http://localhost:12345/artifactory/abc/subfolder')

cs.parts
# ('http://localhost:123...rtifactory', 'subfolder')

We can workaround this by casting to str and back to a path object:

cn = ArtifactoryPath(str(cr.path))

cn
# ArtifactoryPath('http://localhost:12345/artifactory/abc/')

cn.parts
# ('http://localhost:123...ctory/abc/',)

briantist avatar Oct 09 '22 01:10 briantist