fake-s3 icon indicating copy to clipboard operation
fake-s3 copied to clipboard

Fix issue 22 'No objects after restart of fakes3'

Open mark2997 opened this issue 10 years ago • 4 comments

See https://github.com/jubos/fake-s3/issues/22 This is the fix from dterhorst from 25 Jan 2014. The fix worked well for me on Fedora 20

mark2997 avatar Sep 26 '14 04:09 mark2997

Hi, @mark2997, i think this solution only get objects that are stored in the root folder. I have to adapt it like this to make it working for the nested folders:

  private
    def get_objects bucket_name, path, root_path=nil
      if root_path.nil?
        root_path = path
      end

      objects = []
      Dir.new(path).each do |pathname|
        next if ['.', '..'].include?(pathname)
        if pathname == SHUCK_METADATA_DIR
          objects << get_object(bucket_name, path[root_path.length..-1], nil)
        else
          objects += get_objects(bucket_name, File.join(path, pathname), root_path)
        end
      end
      return objects
    end
  end

Allactaga avatar Feb 05 '15 09:02 Allactaga

Allactaga - This almost worked for me - I found that it restored the objects with an extra slash at the start of the key (on Linux). There was an out-by-one error and I had to change the following line:

      objects << get_object(bucket_name, path[root_path.length..-1], nil)

to this:

      objects << get_object(bucket_name, path[root_path.length+1..-1], nil)

mark2997 avatar May 03 '15 21:05 mark2997

Hey, I would really like this patch to be included in the master branch! Desperately need the ability to restart the server without loosing all uploaded items on my project....

SimonKenyonShepard avatar May 27 '15 15:05 SimonKenyonShepard

Why this changes are not merged ?? Or is there any alternate solution to get back all keys after restart

ganeshgore avatar Apr 08 '17 18:04 ganeshgore