diff -rN -u old-597-sync/src/allmydata/scripts/cli.py new-597-sync/src/allmydata/scripts/cli.py --- old-597-sync/src/allmydata/scripts/cli.py 2009-01-29 12:06:18.000000000 -0800 +++ new-597-sync/src/allmydata/scripts/cli.py 2009-01-29 12:06:19.000000000 -0800 @@ -188,6 +188,16 @@ def getSynopsis(self): return "%s ln FROM TO" % (os.path.basename(sys.argv[0]),) +class SyncOptions(VDriveOptions): + def parseArgs(self, localdir, topath): + self.from_dir = localdir + self.to_dir = topath + + def getSynopsis(Self): + return "%s sync FROM ALIAS:TO" % os.path.basename(sys.argv[0]) + + longdesc = """Make a (tahoe) target directory look exactly like a (local) directory. Behaves like 'rsync -a --delete'.""" + class WebopenOptions(VDriveOptions): def parseArgs(self, where=''): self.where = where @@ -264,6 +274,7 @@ ["rm", None, RmOptions, "Unlink a file or directory in the virtual drive."], ["mv", None, MvOptions, "Move a file within the virtual drive."], ["ln", None, LnOptions, "Make an additional link to an existing file."], + ["sync", None, SyncOptions, "Make target dir look like local dir."], ["webopen", None, WebopenOptions, "Open a webbrowser to the root_dir"], ["manifest", None, ManifestOptions, "List all files/dirs in a subtree"], ["stats", None, StatsOptions, "Print statistics about all files/dirs in a subtree"], @@ -335,6 +346,11 @@ rc = tahoe_mv.mv(options, mode="link") return rc +def sync(options): + from allmydata.scripts import tahoe_sync + rc = tahoe_sync.sync(options) + return rc + def webopen(options, opener=None): from allmydata.scripts import tahoe_webopen rc = tahoe_webopen.webopen(options, opener=opener) @@ -372,6 +388,7 @@ "rm": rm, "mv": mv, "ln": ln, + "sync": sync, "webopen": webopen, "manifest": manifest, "stats": stats, diff -rN -u old-597-sync/src/allmydata/scripts/tahoe_sync.py new-597-sync/src/allmydata/scripts/tahoe_sync.py --- old-597-sync/src/allmydata/scripts/tahoe_sync.py 1969-12-31 16:00:00.000000000 -0800 +++ new-597-sync/src/allmydata/scripts/tahoe_sync.py 2009-01-29 12:06:19.000000000 -0800 @@ -0,0 +1,27 @@ + +import os.path +import urllib +import simplejson +from allmydata.scripts.common import get_alias, escape_path, DefaultAliasMarker +from allmydata.scripts.common_http import do_http +from allmydata import uri + +def sync(options): + nodeurl = options['node-url'] + from_dir = options.from_dir + to_dir = options.to_dir + if options['quiet']: + verbosity = 0 + else: + verbosity = 2 + stdin = options.stdin + stdout = options.stdout + stderr = options.stderr + + if nodeurl[-1] != "/": + nodeurl += "/" + rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS) + url = nodeurl + "uri/%s/" % urllib.quote(rootcap) + if path: + url += escape_path(path) +