cloud-storage-rs icon indicating copy to clipboard operation
cloud-storage-rs copied to clipboard

Support Objects rewrite completely/correctly

Open ralpha opened this issue 3 years ago • 1 comments

Currently Objects rewrite is not fully supported. The is because the requester should check if the done flag is set to true, as described here:

This method copies data using multiple requests so large objects can be copied with a normal length timeout per request rather than one very long timeout for a single request. In such cases, you must keep calling the endpoint until the rewrite response done flag is true. If the flag is false, include the rewriteToken that's returned in the response in the subsequent request. [...] --- https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite

In order to properly support this, the request should be repeated as described by the documentation. Right now the code does not check if the flag is set to done. And just returns the Object. Although it does look like (reading for documentation) the resource item will only be present if the rewrite is completed in that 1 transaction. So the deserialization will fail because the resource in RewriteResponse is not marked as Option<Object>.

So currently the function call will fail on the deserialization if the object failed to transfer. Which is less then ideal. It should do multiple transactions or fail by checking if the done flag was set to false.

ralpha avatar Aug 06 '21 10:08 ralpha

Yeah that is indeed a mistake. A pull request that fixes this is definitely welcome!

ThouCheese avatar Sep 25 '21 21:09 ThouCheese