gogoair / lavatory

Tooling to define repository specific retention policies in Artifactory.
Apache License 2.0
21 stars 14 forks source link

move_artifacts fails for root-level artifacts #39

Open mgriffin13 opened 5 years ago

mgriffin13 commented 5 years ago

I have a repo with root level artifacts, and when I try to run a move_artifacts operation, lavatory crashed with this message:

requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://artifactory.example/artifactory/api/move/yum-local/./pkgname.rpm?to=/yum-archive/./pkgname.rpm

Artifactory had a more detailed error:

2019-01-11 13:58:48,418 [http-nio-8081-exec-1] [ERROR] (o.a.a.r.CopyMoveHelper:99) - Failed to move from src=yum-local/./pkgname.rpm to target=/yum-archive/./pkgname.rpm: Path element cannot end with a dot: yum-archive/./pkgname.rpm: Path element cannot end with a dot: yum-archive/./pkgname.rpm

I was able to fix the issue with this hack at https://github.com/gogoair/lavatory/blob/master/src/lavatory/utils/artifactory.py#L101

move_url = "{0}/{1}/{2}{3}/{1}/{2}".format(base_endpoint, artifact['path'] if artifact['path'] != '.' else "/", artifact['name'], dest_prefix)