コード例 #1
0
ファイル: clone-mgr.c プロジェクト: pombredanne/seafile
static void
merge_job_done (void *data)
{
    MergeAux *aux = data;
    CloneTask *task = aux->task;

    if (!aux->success) {
        g_free (aux);
        transition_to_error (task, CLONE_ERROR_MERGE);
        return;
    }

    seaf_repo_manager_set_repo_worktree (aux->repo->manager,
                                         aux->repo,
                                         task->worktree);

    if (task->state == CLONE_STATE_CANCEL_PENDING)
        transition_state (task, CLONE_STATE_CANCELED);
    else if (task->state == CLONE_STATE_MERGE)
        transition_state (task, CLONE_STATE_DONE);
    else
        g_assert (0);

    g_free (aux);
}
コード例 #2
0
ファイル: clone-mgr.c プロジェクト: break123/seafile
static void
merge_job_done (void *data)
{
    MergeAux *aux = data;
    CloneTask *task = aux->task;
    SeafRepo *repo = aux->repo;

    if (!aux->success) {
        g_free (aux);
        transition_to_error (task, CLONE_ERROR_MERGE);
        return;
    }

    seaf_repo_manager_set_repo_worktree (aux->repo->manager,
                                         aux->repo,
                                         task->worktree);

    if (task->state == CLONE_STATE_CANCEL_PENDING)
        transition_state (task, CLONE_STATE_CANCELED);
    else if (task->state == CLONE_STATE_MERGE) {
        /* Save repo head if for GC. */
        seaf_repo_manager_set_repo_property (seaf->repo_mgr,
                                             repo->id,
                                             REPO_REMOTE_HEAD,
                                             repo->head->commit_id);
        transition_state (task, CLONE_STATE_DONE);
    } else
        g_assert (0);

    g_free (aux);
}
コード例 #3
0
ファイル: clone-mgr.c プロジェクト: haiwen/seafile
static void
mark_clone_done_v2 (SeafRepo *repo, CloneTask *task)
{
    SeafBranch *local = NULL;

    seaf_repo_manager_set_repo_worktree (repo->manager,
                                         repo,
                                         task->worktree);

    local = seaf_branch_manager_get_branch (seaf->branch_mgr, repo->id, "local");
    if (!local) {
        seaf_warning ("Cannot get branch local for repo %s(%.10s).\n",
                      repo->name, repo->id);
        transition_to_error (task, CLONE_ERROR_INTERNAL);
        return;
    }
    /* Set repo head to mark checkout done. */
    seaf_repo_set_head (repo, local);
    seaf_branch_unref (local);

    if (repo->encrypted) {
        if (seaf_repo_manager_set_repo_passwd (seaf->repo_mgr,
                                               repo,
                                               task->passwd) < 0) {
            seaf_warning ("[Clone mgr] failed to set passwd for %s.\n", repo->id);
            transition_to_error (task, CLONE_ERROR_INTERNAL);
            return;
        }
    }

    if (task->is_readonly) {
        seaf_repo_set_readonly (repo);
    }

    if (task->sync_wt_name) {
        seaf_repo_manager_set_repo_property (seaf->repo_mgr,
                                             repo->id,
                                             REPO_SYNC_WORKTREE_NAME,
                                             "true");
    }

    if (task->server_url)
        repo->server_url = g_strdup(task->server_url);

    if (repo->auto_sync && (repo->sync_interval == 0)) {
        if (seaf_wt_monitor_watch_repo (seaf->wt_monitor,
                                        repo->id, repo->worktree) < 0) {
            seaf_warning ("failed to watch repo %s(%.10s).\n", repo->name, repo->id);
            transition_to_error (task, CLONE_ERROR_INTERNAL);
            return;
        }
    }

    /* For compatibility, still set these two properties.
     * So that if we downgrade to an old version, the syncing can still work.
     */
    seaf_repo_manager_set_repo_property (seaf->repo_mgr,
                                         repo->id,
                                         REPO_REMOTE_HEAD,
                                         repo->head->commit_id);
    seaf_repo_manager_set_repo_property (seaf->repo_mgr,
                                         repo->id,
                                         REPO_LOCAL_HEAD,
                                         repo->head->commit_id);

    transition_state (task, CLONE_STATE_DONE);
}