Fix s3 registry garbage collect panic
These commits should address the issue described here: omnibus-gitlab#4719 (closed) and are taken from this PR https://github.com/docker/distribution/pull/2879, which is merged into master, but not in an upstream release yet.
Edited by Hayley Swimelar