Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Created July 10, 2013 07:01
Show Gist options
  • Save benhoskings/5964038 to your computer and use it in GitHub Desktop.
Save benhoskings/5964038 to your computer and use it in GitHub Desktop.

This just bit me in production and I'm incredibly unimpressed.

ids = [...] # A list of string ids I generated locally

s = Fog::Storage.new :provider => 'Rackspace', :rackspace_username => '...', :rackspace_api_key => '...'
d = s.directories.detect {|d| d.key == 'corkboard_transfers' }

That directory contained about 3900 files. ids has 19 entries, all of which matched:

d.files.select {|f| ids.include?(f.key) }.length #=> 19

Then I ran this command:

d.files.select {|f| ids.include?(f.key) }.each(&:destroy)

It seemed to be taking a bit long so I cancelled it and checked the bucket with d.reload. It looks like the select condition was ignored and fog started deleting everything in the bucket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment