Skip to content

When using Google Cloud storage, bucket.deleteFile removes all files #292

@jeremywrnr

Description

@jeremywrnr

google cloud bucket issue

The lines from the very helpful Google Cloud getting started page:

   // Intercept file's collection remove method to remove file from Google Cloud Storage
  var _origRemove = Collections.files.remove;

  Collections.files.remove = function(search) {
    var cursor = this.collection.find(search);
    cursor.forEach(function(fileRef) {
      _.each(fileRef.versions, function(vRef) {
        var ref;
        if (vRef != null ? (ref = vRef.meta) != null ? ref.pipePath : void 0 : void 0) {
          bucket.deleteFiles(vRef.meta.pipePath, function(error) {
            bound(function() {
              if (error) {
                console.error(error);
              }
            });
          });
        }
      });
    });
    // Call the original removal method
    _origRemove.call(this, search);
  };

actually wipe out all of the my files hosted in the google cloud storage instance. This may be an more of an issue with how the demo code is interfacing with the bucket than this package, but I figured it was worth posting in case anyone else has experience this issue. Right now I am just opting to not overwrite the remote deletion method, and remove it from the local collection while allowing it to persist on Google Cloud.

For reference, here is the code that I am using which I experience this issue with:
https://github.com/radiolarian/mewsician/blob/master/both/gcloud.js#L174-L183

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions