Skip to content

Commit

Permalink
Merge pull request #969 from jyelee/master
Browse files Browse the repository at this point in the history
enable http-sync for seaf-cli
  • Loading branch information
killing committed Dec 16, 2014
2 parents ec669e1 + eaa25e7 commit f4f30ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions app/seaf-cli
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import time
import getpass
import urllib
import urllib2
from urlparse import urlparse

import ccnet
import seafile
Expand Down Expand Up @@ -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 '''
Expand Down Expand Up @@ -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:
Expand All @@ -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)



Expand Down Expand Up @@ -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: ")
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions python/seafile/rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f4f30ad

Please sign in to comment.