diff --git a/app/seaf-cli b/app/seaf-cli index 68f2264d8..6b249b16e 100755 --- a/app/seaf-cli +++ b/app/seaf-cli @@ -80,6 +80,7 @@ import time import getpass import urllib import urllib2 +from urlparse import urlparse import ccnet import seafile @@ -342,6 +343,15 @@ def seaf_list(args): for repo in repos: print repo.name, repo.id, repo.worktree +def get_base_url(url): + parse_result = urlparse(url) + scheme = parse_result.scheme + netloc = parse_result.netloc + + if scheme and netloc: + return '%s://%s' % (scheme, netloc) + + return None def seaf_download(args): '''Download a library from seafile server ''' @@ -398,6 +408,13 @@ def seaf_download(args): repo_name = tmp['repo_name'] version = tmp.get('repo_version', 0) + more_info = None + use_http = seafile_rpc.get_config("enable_http_sync") + if use_http and bool(use_http): + base_url = get_base_url(url) + if base_url: + more_info = json.dumps({'server_url': base_url}) + print "Starting to download ..." print "Library %s will be downloaded to %s" % (repo, download_dir) if encrypted == 1: @@ -414,7 +431,7 @@ def seaf_download(args): repo_passwd, magic, relay_addr, relay_port, - email, random_key, enc_version) + email, random_key, enc_version, more_info) @@ -476,6 +493,13 @@ def seaf_sync(args): repo_name = tmp['repo_name'] version = tmp.get('repo_version', 0) + more_info = None + use_http = seafile_rpc.get_config("enable_http_sync") + if use_http and bool(use_http): + base_url = get_base_url(url) + if base_url: + more_info = json.dumps({'server_url': url}) + print "Starting to download ..." if encrypted == 1: repo_passwd = getpass.getpass("Enter password for the library: ") @@ -491,7 +515,7 @@ def seaf_sync(args): repo_passwd, magic, relay_addr, relay_port, - email, random_key, enc_version) + email, random_key, enc_version, more_info) def seaf_desync(args): diff --git a/python/seafile/rpcclient.py b/python/seafile/rpcclient.py index 81fe915e9..e8e0fbef1 100644 --- a/python/seafile/rpcclient.py +++ b/python/seafile/rpcclient.py @@ -106,12 +106,12 @@ def gen_default_worktree(worktree_parent, repo_name): pass @searpc_func("string", ["string", "int", "string", "string", "string", "string", "string", "string", "string", "string", "string", "int", "string"]) - def seafile_clone(repo_id, repo_version, peer_id, repo_name, worktree, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, server_url): + def seafile_clone(repo_id, repo_version, peer_id, repo_name, worktree, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, more_info): pass clone = seafile_clone @searpc_func("string", ["string", "int", "string", "string", "string", "string", "string", "string", "string", "string", "string", "int", "string"]) - def seafile_download(repo_id, repo_version, peer_id, repo_name, wt_parent, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, server_url): + def seafile_download(repo_id, repo_version, peer_id, repo_name, wt_parent, token, password, magic, peer_addr, peer_port, email, random_key, enc_version, more_info): pass download = seafile_download