cloud-storage-rs
cloud-storage-rs copied to clipboard
Support Objects rewrite completely/correctly
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 istrue
. If the flag isfalse
, include therewriteToken
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
.
Yeah that is indeed a mistake. A pull request that fixes this is definitely welcome!