krobertson / deb-s3

Easily create and manage an APT repository on S3 -- NO LONGER MAINTAINED
MIT License
482 stars 148 forks source link

Method missing `public_url` in #<Seahorse::Client::Response> with --fail-if-exists #141

Closed agimenez closed 6 years ago

agimenez commented 6 years ago

Hi,

I'm trying the --fail-if-exists feature and I get hist backtrace:

>> Retrieving existing manifests
>> Examining package file package-name.deb
>> Uploading packages and new manifests to S3
   -- Transferring pool/p/a/package-name.deb
/home/agimenez/.rvm/rubies/ruby-2.4.0-rc1/lib/ruby/2.4.0/delegate.rb:87:in `method_missing': undefined method `public_url' for #<Seahorse::Client::Response:0x00557a6141cfe0> (NoMethodError)
Did you mean?  public_send
        from /data/git/github/deb-s3/lib/deb/s3/utils.rb:85:in `s3_store'
        from /data/git/github/deb-s3/lib/deb/s3/manifest.rb:109:in `block in write_to_s3'
        from /data/git/github/deb-s3/lib/deb/s3/manifest.rb:107:in `each'
        from /data/git/github/deb-s3/lib/deb/s3/manifest.rb:107:in `write_to_s3'
        from /data/git/github/deb-s3/lib/deb/s3/cli.rb:245:in `block in upload'
        from /data/git/github/deb-s3/lib/deb/s3/cli.rb:243:in `each_value'
        from /data/git/github/deb-s3/lib/deb/s3/cli.rb:243:in `upload'
        from /home/agimenez/.rvm/gems/ruby-2.4.0-rc1/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
        from /home/agimenez/.rvm/gems/ruby-2.4.0-rc1/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/agimenez/.rvm/gems/ruby-2.4.0-rc1/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
        from /home/agimenez/.rvm/gems/ruby-2.4.0-rc1/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
        from bin/deb-s3:9:in `<main>'

I have checked the code and lin utils.rb:85:

raise AlreadyExistsError, "file #{obj.public_url} already exists with different contents" if fail_if_exists

obj comes from line 78:

     obj = s3_exists?(filename)

That method does a HEAD on the object:

  def s3_exists?(path)
    Deb::S3::Utils.s3.head_object(
      :bucket => Deb::S3::Utils.bucket,
      :key => s3_path(path),
    )
  rescue Aws::S3::Errors::NotFound
    false
  end

That returns a Aws::S3::Types::HeadObjectOutput that does not have that method. I have checked the API documentation and it only retrieves metadata, so the name is not available and we should get it some other way.

I'm trying to write a fix for this.

agimenez commented 6 years ago

@krobertson PR issued, can you please take a look at it?

Thanks, L. Alberto