Fix empty delete requests with Swift fs driver

The Delete method lists objects under the given path and tries to delete
all of them with a bulk delete request. If the path has no objects
underneath it, the body of this request will be empty, which causes
HTTP-level issues. Specifically, Go's HTTP client senses the empty
request buffer and doesn't include a Content-Length, which causes the
Swift server to fail the request.

This commit fixes the problem by avoiding sending empty bulk delete
requests. This is the correct thing to do anyway, since there's no
reason to request deletion of zero objects.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
Aaron Lehmann 2015-11-09 15:33:05 -08:00
parent 057284b593
commit accfa46f9b

View file

@ -587,7 +587,7 @@ func (d *driver) Delete(ctx context.Context, path string) error {
return err return err
} }
if d.BulkDeleteSupport { if len(objects) > 0 && d.BulkDeleteSupport {
filenames := make([]string, len(objects)) filenames := make([]string, len(objects))
for i, obj := range objects { for i, obj := range objects {
filenames[i] = obj.Name filenames[i] = obj.Name