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.