Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* S3/Config.py: Store more file attributes in sync to S3.
* s3cmd: Make sync remote2local more error-resilient.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@182 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
ludvigm committed Jun 4, 2008
1 parent 0f4094f commit dd17190
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2008-06-05 Michal Ludvig <michal@logix.cz>

* S3/Config.py: Store more file attributes in sync to S3.
* s3cmd: Make sync remote2local more error-resilient.

2008-06-04 Michal Ludvig <michal@logix.cz>

* s3cmd: Implemented cmd_sync_remote2local() for restoring
Expand Down
5 changes: 3 additions & 2 deletions S3/Config.py
Expand Up @@ -29,9 +29,10 @@ class Config(object):
preserve_attrs = True
preserve_attrs_list = [
'uname', # Verbose owner Name (e.g. 'root')
#'uid', # Numeric user ID (e.g. 0)
'uid', # Numeric user ID (e.g. 0)
'gname', # Group name (e.g. 'users')
#'gid', # Numeric group ID (e.g. 100)
'gid', # Numeric group ID (e.g. 100)
'atime', # Last access timestamp
'mtime', # Modification timestamp
'ctime', # Creation timestamp
'mode', # File mode (e.g. rwxr-xr-x = 755)
Expand Down
10 changes: 5 additions & 5 deletions S3/Utils.py
Expand Up @@ -143,9 +143,9 @@ def hash_file_md5(filename):
f.close()
return h.hexdigest()

def mkdir_with_parents(dir_name, mode):
def mkdir_with_parents(dir_name):
"""
mkdir_with_parents(dst_dir, mode)
mkdir_with_parents(dst_dir)
Create directory 'dir_name' with all parent directories
Expand All @@ -161,10 +161,10 @@ def mkdir_with_parents(dir_name, mode):
try:
debug("mkdir(%s)" % cur_dir)
os.mkdir(cur_dir)
except IOError, e:
error("%s: can not make directory: %s" % (cur_dir, e.strerror))
except (OSError, IOError), e:
warning("%s: can not make directory: %s" % (cur_dir, e.strerror))
return False
except Exception, e:
error("%s: %s" % (cur_dir, e))
warning("%s: %s" % (cur_dir, e))
return False
return True
14 changes: 10 additions & 4 deletions s3cmd
Expand Up @@ -441,7 +441,7 @@ def cmd_sync_remote2local(src, dst):
try:
dst_dir = os.path.dirname(dst_file)
if not dir_cache.has_key(dst_dir):
dir_cache[dst_dir] = Utils.mkdir_with_parents(dst_dir, mode = 022)
dir_cache[dst_dir] = Utils.mkdir_with_parents(dst_dir)
if dir_cache[dst_dir] == False:
warning("%s: destination directory not writable: %s" % (file, dst_dir))
continue
Expand All @@ -463,14 +463,20 @@ def cmd_sync_remote2local(src, dst):
attrs = _parse_attrs_header(response['headers']['x-amz-meta-s3cmd-attrs'])
if attrs.has_key('mode'):
os.chmod(dst_file, int(attrs['mode']))
## FIXME: uid/gid and mtime/ctime handling comes here! TODO
if attrs.has_key('mtime') or attrs.has_key('atime'):
mtime = attrs.has_key('mtime') and int(attrs['mtime']) or int(time.time())
atime = attrs.has_key('atime') and int(attrs['atime']) or int(time.time())
os.utime(dst_file, (atime, mtime))
## FIXME: uid/gid / uname/gname handling comes here! TODO
except OSError, e:
if e.errno == errno.EEXIST:
warning("%s exists - not overwriting" % (dst_file))
continue
if e.errno in (errno.EPERM, errno.EACCES):
warning("%s not writable: %s" % (dst_file, e.strerror))
continue
raise
except IOError, e:
## See if it's missing path and try again
except Exception, e:
error("%s: %s" % (file, e))
continue
finally:
Expand Down

0 comments on commit dd17190

Please sign in to comment.