예제 #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='',
                                  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)
예제 #3
0
    def show_repo(self, repo_id):
        repo = seafile_rpc.get_repo(repo_id)
        if not repo:
            return render.repo_missing(repo_id=repo_id, **default_options)

        try:
            prepare_repo_info(repo)
            recent_commits = get_commits(repo_id, 0, 3)
            repo.is_broken = False
        except SearpcError, e:
            repo.is_broken = True
            recent_commits = []
            repo.error_msg = e.msg
예제 #4
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)
예제 #5
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)
예제 #6
0
파일: main.py 프로젝트: hcnhjxox/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_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
        )
예제 #7
0
    def show_repo_history(self, repo_id):
        repo = seafile_rpc.get_repo(repo_id)
        prepare_repo_info(repo)
        inputs = web.webapi.input(page="1", per_page="25")
        current_page = int(inputs.page)
        per_page = int(inputs.per_page)
        commits_all = get_commits(repo_id, per_page * (current_page - 1), per_page + 1)
        commits = commits_all[:per_page]
        if len(commits_all) == per_page + 1:
            page_next = True
        else:
            page_next = False

        return render.repo_history(repo=repo, 
                           commits=commits,
                           current_page=current_page,
                           per_page=per_page,
                           page_next=page_next,
                           **default_options)
예제 #8
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)