Skip to content
Browse files

Implementation of --follow-symlinks option (nonrecursive case)

  • Loading branch information...
1 parent 4f8a35b commit 7b5df26288c6f719ea21e1ec8c4900c2abb608ff @redsymbol redsymbol committed Jul 17, 2010
Showing with 12 additions and 8 deletions.
  1. +1 −0 S3/Config.py
  2. +5 −5 run-tests.py
  3. +6 −3 s3cmd
View
1 S3/Config.py
@@ -74,6 +74,7 @@ class Config(object):
urlencoding_mode = "normal"
log_target_prefix = ""
reduced_redundancy = False
+ follow_symlinks=False
## Creating a singleton
def __new__(self, configfile = None):
View
10 run-tests.py
@@ -335,7 +335,7 @@ def pbucket(tail):
## ====== Sync more to S3
test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
must_find = [ "File 'testsuite/.svn/entries' stored as '%s/xyz/.svn/entries' " % pbucket(1) ],
- must_not_find_re = [ "linked.png"])
+ must_not_find = [ "File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png" % pbucket(1) ])
@@ -392,6 +392,10 @@ def pbucket(tail):
"File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
must_not_find = [ ".svn" ])
+## ====== Sync symbolic links
+test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt', '--follow-symlinks' ],
+ must_find_re = [ "linked.png"])
+
## ====== Verify ACL and MIME type
test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "MIME type:.*image/png",
@@ -440,7 +444,3 @@ def pbucket(tail):
test_s3cmd("Remove remaining buckets", ['rb', '--recursive', pbucket(2), pbucket(3)],
must_find = [ "Bucket '%s/' removed" % pbucket(2),
"Bucket '%s/' removed" % pbucket(3) ])
-
-## ====== Sync symbolic links
-test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
- must_find_re = [ "linked.png"])
View
9 s3cmd
@@ -635,9 +635,8 @@ def _get_filelist_local(local_uri):
if not os.path.isfile(full_name):
continue
if os.path.islink(full_name):
- ## Synchronize symlinks... one day
- ## for now skip over
- continue
+ if not cfg.follow_symlinks:
+ continue
relative_file = unicodise(os.path.join(rel_root, f))
if os.path.sep != "/":
# Convert non-unix dir separators to '/'
@@ -1623,6 +1622,7 @@ def main():
optparser.add_option("-v", "--verbose", dest="verbosity", action="store_const", const=logging.INFO, help="Enable verbose output.")
optparser.add_option("-d", "--debug", dest="verbosity", action="store_const", const=logging.DEBUG, help="Enable debug output.")
optparser.add_option( "--version", dest="show_version", action="store_true", help="Show s3cmd version (%s) and exit." % (PkgInfo.version))
+ optparser.add_option("-F", "--follow-symlinks", dest="follow_symlinks", action="store_true", default=False, help="Follow symbolic links as if they are regular files")
optparser.set_usage(optparser.usage + " COMMAND [parameters]")
optparser.set_description('S3cmd is a tool for managing objects in '+
@@ -1757,6 +1757,9 @@ def main():
cfg.include.extend(patterns_list)
cfg.debug_include.update(patterns_textual)
+ ## Process --follow-symlinks
+ cfg.update_option("follow_symlinks", options.follow_symlinks)
+
if cfg.encrypt and cfg.gpg_passphrase == "":
error(u"Encryption requested but no passphrase set in config file.")
error(u"Please re-run 's3cmd --configure' and supply it.")

0 comments on commit 7b5df26

Please sign in to comment.
Something went wrong with that request. Please try again.