Beispiel #1
0
    def GET(self):
        ts = []
        tasks = seafile_rpc.get_clone_tasks()
        for task in tasks:
            t = {}
            t['repo_id'] = task.props.repo_id
            t['repo_name'] = task.props.repo_name
            t['state'] = task.props.state
            t['error_str'] = task.props.error_str
            t['worktree'] = task.props.worktree

            tx_task = False
            checkout_task = False
            if task.props.state == "fetch":
                tx_task = seafile_rpc.find_transfer_task(task.props.repo_id)
                t['tx_block_done'] = tx_task.props.block_done
                t['tx_block_total'] = tx_task.props.block_total
            elif task.props.state == "checkout":
                checkout_task = seafile_rpc.get_checkout_task(task.props.repo_id)
                t['checkout_finished_files'] = checkout_task.props.finished_files
                t['checkout_total_files'] = checkout_task.props.total_files
            elif task.props.state == "error" and task.props.error_str == "fetch":
                tx_task = seafile_rpc.find_transfer_task(task.props.repo_id)
                t['tx_error_str'] = tx_task.props.error_str
            elif task.props.state == "error" and task.props.error_str == "password":
                t['relay_id'] = task.props.peer_id

            ts.append(t)

        Tasks = {}
        Tasks['tasks'] = ts
        return json.dumps(Tasks)
Beispiel #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)
Beispiel #3
0
    def GET(self):
        inputs = web.webapi.input(relay_id='',
                                  token='',
                                  relay_addr='',
                                  relay_port='',
                                  repo_id='',
                                  repo_name='',
                                  encrypted='',
                                  magic='',
                                  email='',
                                  enc_ver='',
                                  key='')

        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 not inputs.enc_ver:
            enc_version = 1
        else:
            enc_version = int(inputs.enc_ver)
        random_key = inputs.key

        if seafile_rpc.get_repo(inputs.repo_id):
            return render.repo_sync(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/')

        return render.repo_sync(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='',
                                encrypted=inputs.encrypted,
                                magic=inputs.magic,
                                email=email,
                                enc_version=enc_version,
                                random_key=random_key,
                                **default_options)
Beispiel #4
0
    def GET(self):
        inputs = web.webapi.input(op='', repo_id='')
        if inputs.op and inputs.repo_id:
            if inputs.op == "remove":
                seafile_rpc.remove_clone_task(inputs.repo_id)
            elif inputs.op == "cancel":
                seafile_rpc.cancel_clone_task(inputs.repo_id)
            raise web.seeother('/repos/download-tasks/')

        tasks = seafile_rpc.get_clone_tasks()

        return render.clone_tasks(tasks=tasks,
                                  **default_options)
Beispiel #5
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)
Beispiel #6
0
    def GET(self):
        inputs = web.webapi.input(relay_id='', token='',
                                  relay_addr='', relay_port = '',
                                  repo_id='', repo_name='',
                                  encrypted='', magic='', email='',
                                  enc_ver='', key='')

        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 not inputs.enc_ver:
            enc_version = 1
        else:
            enc_version = int(inputs.enc_ver)
        random_key = inputs.key

        if seafile_rpc.get_repo(inputs.repo_id):
            return render.repo_sync(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/')

        return render.repo_sync(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='',
                                encrypted=inputs.encrypted,
                                magic=inputs.magic,
                                email=email,
                                enc_version=enc_version,
                                random_key=random_key,
                                **default_options)
Beispiel #7
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_sync(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/")

        return render.repo_sync(
            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="",
            encrypted=inputs.encrypted,
            magic=inputs.magic,
            email=email,
            **default_options
        )
Beispiel #8
0
    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)