Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Google buckets storage. #172

Closed
wants to merge 10 commits into from

Conversation

alexanderfast
Copy link
Contributor

What does this PR do?

Adds support for Google buckets storage.

Motivation

Needed for persistent storage.

@alexanderfast
Copy link
Contributor Author

Named the new project BaGet.GCP rather than BaGet.Gcp to match capitalization of aws project, I'm not sure which you prefer.

if (e.HttpStatusCode != HttpStatusCode.NotFound)
throw;

await storage.UploadObjectAsync(_bucketName, path, contentType, content, cancellationToken: cancellationToken);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this throw a GoogleApiException if the object already exists? If so, you should catch that, get a hash of the already existing object, and return AlreadyExists if the object has the same content or Conflict if the object has different content. See the Azure Blob Storage code for an example: https://github.com/loic-sharma/BaGet/blob/master/src/BaGet.Azure/BlobStorageService.cs#L68

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, UploadObjectAsync silently overwrites. It has a UploadObjectOptions parameter but setting its IfGenerationNotMatch property only seems to silently overwrite or ignore, you're not told what happened. I instead opted for using the path as "key", if the package already exists youre not allowed to overwrite, regardless of if the content has changed. Is that acceptable?

{
try
{
await storage.GetObjectAsync(_bucketName, CoercePath(path), cancellationToken: cancellationToken);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right. The steps should be something like:

  1. Attempt to UploadObjectAsync
  2. If the upload fails because the file exists (likely a HttpStatusCode.Conflict, but please verify this as I've never used GCP), then:
    1. Download the object
    2. Return PutResult.AlreadyExists if the object is the same as content, or PutResult.Conflict otherwise.

For an example of this, please see Azure's BlobStorageService

bgrainger added a commit to bgrainger/BaGet that referenced this pull request Mar 13, 2019
bgrainger added a commit to bgrainger/BaGet that referenced this pull request Mar 18, 2019
bgrainger added a commit to bgrainger/BaGet that referenced this pull request Mar 18, 2019
@bgrainger
Copy link
Contributor

@loic-sharma This has been superseded by #233 and can be closed.

@loic-sharma
Copy link
Owner

Yes it can, thanks for the reminder! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants