February 02, 2014, 01:27:45 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / Feature Requests / Re: Preserve modification times? on: June 04, 2008, 05:48:07 PM
I've got it to work for what I need, it is probably really bad code but it works... Here it is, I would use this at your own risk. It uses touch to update the time on the file based on the meta data, if the meta data isn't there then it uses the Last Modified data from Amazon.

In s3sync.rb

               def symlink?()
                        unless @result
                                @result = S3sync.S3try(:head, @bucket, @path)
                        debug("symlink value is:  #{@result.object.metadata['symlink']}")
                        @result.object.metadata['symlink'] == 'true'

                def date2
                         unless @result
                                @result = S3sync.S3try(:head, @bucket, @path)
                        debug("date could be:  #{@result.object.metadata['date']}")


                            s3o = S3::S3Object.new(theStream, meta)
                            headers = {'Content-Length' => (fromNode.size.respond_to?(:nonzero?) ? fromNode.size.to_s : '0')}


                             headers['x-amz-meta-date'] = fromNode.date.to_s

I wasn't sure the proper place to put this, but I grouped it with the chmod/chown because it was modifying the file so I figured it was a good place to stick it.

                                # clean up if the temp file is still there (as for links)
                                File.unlink(fName) if File.exist?(fName)
                                # update permissions
                                linkCommand = fromNode.symlink? ? 'l' : ''

                                        if fromNode.date2.to_s == ""
                                                thedate = fromNode.date.to_s
                                                thedate = fromNode.date2.to_s
                                        file = @path
                                        `touch -d "#{thedate}" #{file}`

2  General Category / Feature Requests / Re: Preserve modification times? on: June 03, 2008, 06:37:53 PM
I'm trying to accomplish the same thing, however I know 0 ruby so I'm having some trouble.

I have been able to add meta data to attach to my s3 files however I can't seem how to get it from S3 back to my local files and run a touch -d command...

Around line 506
Add beneath: meta['symlink'] = 'true' if fromNode.symlink?
meta['date'] = fromNode.date.to_s

When I get the headers on my files I see:
< HTTP/1.1 200 OK
< Date: Tue, 03 Jun 2008 23:26:48 GMT
< x-amz-meta-date: Sun Jun 03 23:34:26 UTC 2007
< x-amz-meta-permissions: 33204
< Last-Modified: Tue, 03 Jun 2008 23:06:48 GMT
< Content-Type:
< Content-Length: 3
< Server: AmazonS3

However I'm not sure how to get this info back and actually use it to modify my local files...

Any ideas?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!