wordpress.rake
# Remove all but KEEP_NUM objects from a particular bucket
Remove all but KEEP_NUM objects from a particular bucket
Remove all but KEEP_NUM objects from a particular bucket
def cleanup_bucket(name, keep_num)
    msg "Cleaning up #{bucket_name(name)} (keeping last #{keep_num})"
    bucket = AWS::S3::Bucket.find(bucket_name(name))
    objects = bucket.objects
    remove = objects.size-keep_num-1
    objects[0..remove].each do |object|
      response = object.delete
    end unless remove < 0
  end
def cleanup_bucket ( name , keep_num ) msg "Cleaning up #{bucket_name(name)} (keeping last #{keep_num})" bucket = AWS :: S3 :: Bucket . find ( bucket_name ( name ) ) objects = bucket . objects remove = objects . size - keep_num - 1 objects [ 0 .. remove ] . each do | object | response = object . delete end unless remove < 0 end
Remove all but KEEP_NUM objects from a particular bucket
Remove all but KEEP_NUM objects from a particular bucket
name
<not_specific>
keep_num
<not_specific>