Skip to content

Storage: add support for deleting specific blob generations #5781

@sdigit

Description

@sdigit

OS: Debian Stretch
Python 3.6.6
google-cloud-storage 1.10.0

In the following scenario, the API will return versioned blobs. However, it is unable to delete a specific version, as the Blob.delete method does not take a generation parameter nor does Bucket.delete_blob.

from google.cloud.storage import Client
client = Client(project='project-name')
bucket = client.get_bucket('foobar')
blobs = bucket.list_blobs(versions=True)

blobs will iterate over all versions, but calling .delete() on any of them will always delete the current version as the delete code does not supply ?generation=<generation> in the request.

This leads to unintentional data loss when trusting blob.delete() to delete that specific blob.

Ideally, blob.delete() would delete the generation corresponding to that blob's .generation property (this would mimic boto's behavior).

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions