コード例 #1
0
ファイル: clone-mgr.c プロジェクト: break123/seafile
static gboolean
is_worktree_of_repo (SeafCloneManager *mgr, const char *path)
{
    GList *repos, *ptr;
    SeafRepo *repo;
    GHashTableIter iter;
    gpointer key, value;
    CloneTask *task;

    repos = seaf_repo_manager_get_repo_list (seaf->repo_mgr, -1, -1);
    for (ptr = repos; ptr != NULL; ptr = ptr->next) {
        repo = ptr->data;
        if (g_strcmp0 (path, repo->worktree) == 0) {
            g_list_free (repos);
            return TRUE;
        }
    }
    g_list_free (repos);

    g_hash_table_iter_init (&iter, mgr->tasks);
    while (g_hash_table_iter_next (&iter, &key, &value)) {
        task = value;
        if (task->state == CLONE_STATE_DONE ||
            task->state == CLONE_STATE_ERROR ||
            task->state == CLONE_STATE_CANCELED)
            continue;
        if (g_strcmp0 (path, task->worktree) == 0)
            return TRUE;
    }

    return FALSE;
}
コード例 #2
0
ファイル: clone-mgr.c プロジェクト: c326277320/seafile
static gboolean
check_worktree_path (SeafCloneManager *mgr, const char *path, GError **error)
{
    GList *repos, *ptr;
    SeafRepo *repo;
    GHashTableIter iter;
    gpointer key, value;
    CloneTask *task;

    if (check_dir_inclusiveness (path, seaf->seaf_dir) != 0 ||
        /* It's OK if path is included by the default worktree parent. */
        check_dir_inclusiveness (path, seaf->worktree_dir) < 0 ||
        check_dir_inclusiveness (path, seaf->session->config_dir) != 0) {
        seaf_warning ("Worktree path conflicts with seafile system path.\n");
        g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
                     "Worktree conflicts system path");
        return FALSE;
    }

    repos = seaf_repo_manager_get_repo_list (seaf->repo_mgr, -1, -1);
    for (ptr = repos; ptr != NULL; ptr = ptr->next) {
        repo = ptr->data;
        if (repo->worktree != NULL &&
            check_dir_inclusiveness (path, repo->worktree) != 0) {
            seaf_warning ("Worktree path conflict with repo %s.\n", repo->name);
            g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
                         "Worktree conflicts existing repo");
            g_list_free (repos);
            return FALSE;
        }
    }
    g_list_free (repos);

    g_hash_table_iter_init (&iter, mgr->tasks);
    while (g_hash_table_iter_next (&iter, &key, &value)) {
        task = value;
        if (task->state == CLONE_STATE_DONE ||
            task->state == CLONE_STATE_ERROR ||
            task->state == CLONE_STATE_CANCELED)
            continue;
        if (check_dir_inclusiveness (path, task->worktree) != 0) {
            seaf_warning ("Worktree path conflict with clone %.8s.\n",
                          task->repo_id);
            g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
                         "Worktree conflicts existing repo");
            return FALSE;
        }
    }

    return TRUE;
}
コード例 #3
0
ファイル: verify.c プロジェクト: c326277320/seafile
int
verify_repos ()
{
    GList *repos = NULL, *ptr;
    int ret = 0;

    repos = seaf_repo_manager_get_repo_list (seaf->repo_mgr, -1, -1);
    for (ptr = repos; ptr != NULL; ptr = ptr->next) {
        ret = verify_repo ((SeafRepo *)ptr->data);
        seaf_repo_unref ((SeafRepo *)ptr->data);
        if (ret < 0)
            break;
    }

    return ret;
}
コード例 #4
0
ファイル: sync-mgr.c プロジェクト: break123/seafile
static void
add_repo_relays ()
{
    GList *ptr, *repo_list;

    repo_list = seaf_repo_manager_get_repo_list (seaf->repo_mgr, 0, -1);

    for (ptr = repo_list; ptr; ptr = ptr->next) {
        SeafRepo *repo = ptr->data;
        if (repo->relay_id) {
            add_relay_if_needed (repo);
        }
    }

    g_list_free (repo_list);
}
コード例 #5
0
ファイル: seaf-migrate.c プロジェクト: Danath/seafile
static int
migrate_v0_repos_to_v1_layout ()
{
    GList *repos = NULL, *ptr;
    SeafRepo *repo;
    gboolean error = FALSE;

    repos = seaf_repo_manager_get_repo_list (seaf->repo_mgr, -1, -1, &error);
    for (ptr = repos; ptr; ptr = ptr->next) {
        repo = ptr->data;
        if (!repo->is_corrupted && repo->version == 0)
            migrate_repo (repo);
        seaf_repo_unref (repo);
    }
    g_list_free (repos);

    return 0;
}
コード例 #6
0
ファイル: seaf-tool.c プロジェクト: Jack-Tsue/seafile
static int
do_validate()
{
    GList *repo_list = seaf_repo_manager_get_repo_list(seaf->repo_mgr, -1, -1);
    if (!repo_list) {
        printf ("There is no repo yet.\n");
        return 0;
    }

    GList *ptr = repo_list;
    while(ptr) {
        SeafRepo *repo = ptr->data;
        ptr = ptr->next;
        if (validate_repo(repo) < 0 && !force_continue) {
            return -1;
        }
    }
    return 0;
}
コード例 #7
0
ファイル: seaf-tool.c プロジェクト: Jack-Tsue/seafile
static void
do_list_repos ()
{
    GList *repo_list = seaf_repo_manager_get_repo_list (seaf->repo_mgr, -1, -1);
    if (!repo_list) {
        printf ("You have no repo yet.\n");
        return;
    }
    printf ("You have these repos:\n");

    GList *ptr = repo_list;
    while (ptr) {
        SeafRepo *repo = ptr->data;
        printf ("%s\t%s\n", repo->id, repo->worktree);
        ptr = ptr->next;
    }
    g_list_free (repo_list);

    return;
}