예제 #1
0
파일: main.py 프로젝트: swpd/seafile
    def GET(self):
        inputs = web.webapi.input(relay_id='',
                                  token='',
                                  relay_addr='',
                                  relay_port='',
                                  repo_id='',
                                  repo_name='',
                                  encrypted='',
                                  magic='',
                                  email='')

        relay_id = inputs.relay_id
        token = inputs.token
        relay_addr = inputs.relay_addr
        relay_port = inputs.relay_port
        repo_id = inputs.repo_id
        repo_name = inputs.repo_name
        email = inputs.email

        if seafile_rpc.get_repo(inputs.repo_id):
            return render.repo_download(repo_already_exists=True,
                                        **default_options)

        tasks = seafile_rpc.get_clone_tasks()
        for task in tasks:
            if task.props.repo_id == inputs.repo_id:
                if task.props.state != 'done' and task.props.state != 'error' \
                   and task.props.state != 'canceled':
                    raise web.seeother('/repos/download-tasks/')

        wt_parent = get_default_seafile_worktree()

        sync_url = "/repo/sync/?relay_id=%s&relay_addr=%s&relay_port=%s&" \
            "email=%s&token=%s&repo_id=%s&repo_name=%s" % \
            (relay_id, relay_addr, relay_port, urllib.quote(email), token, repo_id,
             urllib.quote(repo_name.encode('utf-8')))
        if inputs.encrypted:
            sync_url += "&encrypted=1&magic=%s" % inputs.magic

        return render.repo_download(error_msg=None,
                                    repo_already_exists=False,
                                    repo_id=inputs.repo_id,
                                    relay_id=inputs.relay_id,
                                    token=token,
                                    relay_addr=relay_addr,
                                    relay_port=relay_port,
                                    repo_name=repo_name,
                                    wt_parent=wt_parent,
                                    encrypted=inputs.encrypted,
                                    magic=inputs.magic,
                                    email=email,
                                    sync_url=sync_url,
                                    **default_options)
예제 #2
0
    def GET(self):
        inputs = web.webapi.input(relay_id='', token='',
                                  relay_addr='', relay_port = '',
                                  repo_id='', repo_name='',
                                  encrypted='', magic='', email='')

        relay_id   = inputs.relay_id
        token       = inputs.token
        relay_addr = inputs.relay_addr
        relay_port = inputs.relay_port
        repo_id     = inputs.repo_id
        repo_name   = inputs.repo_name
        email       = inputs.email

        if seafile_rpc.get_repo(inputs.repo_id):
            return render.repo_download(repo_already_exists=True,
                                        **default_options)
        
        tasks = seafile_rpc.get_clone_tasks()
        for task in tasks:
            if task.props.repo_id == inputs.repo_id:
                if task.props.state != 'done' and task.props.state != 'error' \
                   and task.props.state != 'canceled': 
                    raise web.seeother('/repos/download-tasks/')

        wt_parent = get_default_seafile_worktree ()

        sync_url = "/repo/sync/?relay_id=%s&relay_addr=%s&relay_port=%s&" \
            "email=%s&token=%s&repo_id=%s&repo_name=%s" % \
            (relay_id, relay_addr, relay_port, urllib.quote(email), token, repo_id,
             urllib.quote(repo_name.encode('utf-8')))
        if inputs.encrypted:
            sync_url += "&encrypted=1&magic=%s" % inputs.magic

        return render.repo_download(error_msg=None,
                                    repo_already_exists=False,
                                    repo_id=inputs.repo_id,
                                    relay_id=inputs.relay_id,
                                    token=token,
                                    relay_addr=relay_addr,
                                    relay_port=relay_port,
                                    repo_name=repo_name,
                                    wt_parent=wt_parent,
                                    encrypted=inputs.encrypted,
                                    magic=inputs.magic,
                                    email=email,
                                    sync_url=sync_url,
                                    **default_options)
예제 #3
0
파일: main.py 프로젝트: sheyong/seafile
    def GET(self):
        inputs = web.webapi.input(relay_id='', token='',
                                  relay_addr='', relay_port = '',
                                  repo_id='', repo_name='',
                                  encrypted='', email='')

        relay_id   = inputs.relay_id
        token       = inputs.token
        relay_addr = inputs.relay_addr
        relay_port = inputs.relay_port
        repo_id     = inputs.repo_id
        repo_name   = inputs.repo_name
        email       = inputs.email

        if seafile_rpc.get_repo(inputs.repo_id):
            return render.repo_download(repo_already_exists=True,
                                        **default_options)
        
        tasks = seafile_rpc.get_clone_tasks()
        for task in tasks:
            if task.props.repo_id == inputs.repo_id:
                if task.props.state != 'done' and task.props.state != 'error' \
                   and task.props.state != 'canceled': 
                    raise web.seeother('/repos/download-tasks/')

        repo_name = urllib.unquote(inputs.repo_name)

        default_seafile_worktree = get_default_seafile_worktree ()
        worktree = seafile_rpc.gen_default_worktree(default_seafile_worktree, repo_name)

        return render.repo_download(error_msg=None,
                                    repo_already_exists=False,
                                    repo_id=inputs.repo_id,
                                    relay_id=inputs.relay_id,
                                    token=token,
                                    relay_addr=relay_addr,
                                    relay_port=relay_port,
                                    repo_name=repo_name,
                                    worktree=worktree,
                                    encrypted=inputs.encrypted,
                                    email=email,
                                    **default_options)