Esempio n. 1
0
static int
send_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    USE_PRIV;
    GString *buf;
    TransferTask *task = ((SeafileSendcommitV3Proc *)processor)->tx_task;

    memcpy (priv->remote_id, task->remote_head, 41);

    /* fs_roots can be non-NULL if transfer is resumed from NET_DOWN. */
    if (task->fs_roots != NULL)
        object_list_free (task->fs_roots);
    task->fs_roots = object_list_new ();

    if (task->commits != NULL)
        object_list_free (task->commits);
    task->commits = object_list_new ();
    
    buf = g_string_new (NULL);
    g_string_printf (buf, "remote %s seafile-recvcommit-v3 %s %s",
                     processor->peer_id, task->to_branch, task->session_token);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    return 0;
}
Esempio n. 2
0
static int
sync_repo_start (CcnetProcessor *processor, int argc, char **argv)
{
    SeafileSyncRepoProc *proc = (SeafileSyncRepoProc *) processor;

    if (argc != 0) {
        seaf_warning ("[sync-repo] argc should be 0.\n");
        ccnet_processor_done (processor, FALSE);
        return 0;
    }

    if (!proc->task) {
        seaf_warning ("[sync-repo] Error: not provide info task.\n");
        ccnet_processor_done (processor, FALSE);
        return 0;
    }

    char buf[256];

    /* Use a virutal "fetch_head" branch that works both on client and server. */
    snprintf (buf, 256, "remote %s seafile-sync-repo-slave %s %s",
              processor->peer_id, proc->task->info->repo_id, "fetch_head");
    
    ccnet_processor_send_request (processor, buf);

    return 0;
}
Esempio n. 3
0
static int
start (CcnetProcessor *processor, int argc, char **argv)
{
    USE_PRIV;
    TransferTask *task = ((SeafileGetfsProc *)processor)->tx_task;
    GString *buf = g_string_new (NULL);

    if (task->session_token)
        g_string_printf (buf, "remote %s seafile-putfs %s", 
                         processor->peer_id, task->session_token);
    else
        g_string_printf (buf, "remote %s seafile-putfs", 
                         processor->peer_id);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    processor->state = REQUEST_SENT;
    priv->inspect_queue = g_queue_new ();
    priv->fs_objects = g_hash_table_new_full (g_str_hash, g_str_equal,
                                              g_free, NULL);

    priv->writer_id = seaf_obj_store_register_async_write (seaf->fs_mgr->obj_store,
                                                           fs_object_write_cb,
                                                           processor);

    return 0;
}
Esempio n. 4
0
static int
get_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    USE_PRIV;
    GString *buf = g_string_new (NULL);
    TransferTask *task = ((SeafileGetcommitV3Proc *)processor)->tx_task;
    SeafBranch *master = NULL;

    g_return_val_if_fail (task->session_token, -1);

    /* fs_roots can be non-NULL if transfer is resumed from NET_DOWN. */
    if (task->fs_roots != NULL)
        object_list_free (task->fs_roots);
    task->fs_roots = object_list_new ();

    priv->writer_id = seaf_obj_store_register_async_write (seaf->commit_mgr->obj_store,
                                                           task->repo_id,
                                                           task->repo_version,
                                                           commit_write_cb, processor);

    g_string_printf (buf, "remote %s seafile-putcommit-v3 %s %s",
                     processor->peer_id, 
                     task->head, task->session_token);

    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    seaf_branch_unref (master);

    return 0;
}
Esempio n. 5
0
static int
send_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    GString *buf;
    int ret;
    TransferTask *task = ((SeafileSendcommitProc *)processor)->tx_task;
    
    ObjectList *ol = object_list_new ();
    ret = seaf_commit_manager_traverse_commit_tree (seaf->commit_mgr,
                                                    task->head,
                                                    commit_collector,
                                                    ol, FALSE);
    if (ret == FALSE) {
        object_list_free (ol);
        seaf_warning ("[sendcommit] Load commits error\n");
        ccnet_processor_done (processor, FALSE);
        return -1;
    }
    g_return_val_if_fail (object_list_length(ol) != 0, -1);
    task->commits = ol;

    /* Send to_branch to the relay. */
    buf = g_string_new (NULL);
    g_string_printf (buf, "remote %s seafile-recvcommit %s %s",
                     processor->peer_id, task->to_branch, task->session_token);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    processor->state = INIT;

    return 0;
}
Esempio n. 6
0
static int
send_msg_start (CcnetProcessor *processor, int argc, char **argv)
{
    char buf[256];
    int len;

    len = snprintf (buf, 256, "receive-msg");
    g_assert(len < 256);
    ccnet_processor_send_request (processor, buf);
    processor->state = REQUEST_SENT;

    return 0;
}
Esempio n. 7
0
static int
send_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    TransferTask *task = ((SeafileSendcommitV4Proc *)processor)->tx_task;
    GString *buf;
    
    buf = g_string_new (NULL);
    g_string_printf (buf, "remote %s seafile-recvcommit-v3 master %s",
                     processor->peer_id, task->session_token);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    return 0;
}
Esempio n. 8
0
static int
start (CcnetProcessor *processor, int argc, char **argv)
{
    if (argc != 0) {
        ccnet_processor_error (processor, SC_BAD_ARGS, SS_BAD_ARGS);
        return -1;
    }
    
    ccnet_processor_send_request (processor, "recvlogout");

    g_signal_connect (processor, "done", (GCallback)logout_done_cb, processor->peer);

    processor->peer->logout_started = TRUE;

    return 0;
}
Esempio n. 9
0
static int
get_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    GString *buf = g_string_new (NULL);
    TransferTask *task = ((SeafileGetcommitProc *)processor)->tx_task;

    if (task->session_token)
        g_string_printf (buf, "remote %s seafile-putcommit %s %s",
                         processor->peer_id, task->head, task->session_token);
    else
        g_string_printf (buf, "remote %s seafile-putcommit %s",
                         processor->peer_id, task->head);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    return 0;
}
Esempio n. 10
0
static int
start (CcnetProcessor *processor, int argc, char **argv)
{
    GString *buf;
    SeafileSendfsProc *proc = (SeafileSendfsProc *)processor;
    TransferTask *task = proc->tx_task;

    buf = g_string_new (NULL);
    g_string_printf (buf, "remote %s seafile-recvfs %s", 
                     processor->peer_id, task->session_token);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    processor->state = SEND_ROOT;
    proc->last_idx = 0;

    return 0;
}
Esempio n. 11
0
static int
start (CcnetProcessor *processor, int argc, char **argv)
{
    USE_PRIV;
    GString *buf;
    SeafileGetfsV2Proc *proc = (SeafileGetfsV2Proc *)processor;
    TransferTask *task = proc->tx_task;

    buf = g_string_new (NULL);
    if (!task->is_clone) {
        SeafBranch *master = seaf_branch_manager_get_branch (seaf->branch_mgr,
                                                             task->repo_id,
                                                             "master");
        if (!master) {
            seaf_warning ("Master branch not found for repo %s.\n", task->repo_id);
            g_string_free (buf, TRUE);
            ccnet_processor_done (processor, FALSE);
            return -1;
        }

        g_string_printf (buf, "remote %s seafile-putfs-v2 %s %s %s",
                         processor->peer_id, task->session_token,
                         task->head, master->commit_id);

        seaf_branch_unref (master);
    } else
        g_string_printf (buf, "remote %s seafile-putfs-v2 %s %s",
                         processor->peer_id, task->session_token,
                         task->head);

    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    priv->registered = TRUE;
    priv->writer_id = seaf_obj_store_register_async_write (seaf->fs_mgr->obj_store,
                                                           task->repo_id,
                                                           task->repo_version,
                                                           on_fs_write,
                                                           processor);
    return 0;
}
Esempio n. 12
0
static int
start (CcnetProcessor *processor, int argc, char **argv)
{
    SeafileCheckTxV3Proc *proc = (SeafileCheckTxV3Proc *)processor;
    TransferTask *task = proc->task;
    char *type, *enc_token;
    GString *buf;

    if (argc != 1) {
        transition_state_to_error (task, TASK_ERR_CHECK_UPLOAD_START);
        ccnet_processor_done (processor, FALSE);
        return -1;
    }

    type = argv[0];
    if (strcmp (type, "upload") == 0)
        proc->type = CHECK_TX_TYPE_UPLOAD;
    else
        proc->type = CHECK_TX_TYPE_DOWNLOAD;

    enc_token = encrypt_token (processor, task->token);
    if (!enc_token) {
        transition_state_to_error (task, TASK_ERR_CHECK_UPLOAD_START);
        ccnet_processor_done (processor, FALSE);
        return -1;
    }

    buf = g_string_new(NULL);
    g_string_append_printf (buf,
              "remote %s seafile-check-tx-slave-v3 %s %d %s %s %s",
              processor->peer_id, type, CURRENT_PROTO_VERSION, 
            task->repo_id, task->to_branch, enc_token);

    ccnet_processor_send_request (processor, buf->str);

    g_free (enc_token);
    g_string_free (buf, TRUE);

    return 0;
}
Esempio n. 13
0
static int
get_commit_start (CcnetProcessor *processor, int argc, char **argv)
{
    GString *buf = g_string_new (NULL);
    TransferTask *task = ((SeafileGetcommitV2Proc *)processor)->tx_task;
    SeafBranch *master = NULL;
    char *end_commit_id = NULL;

    g_return_val_if_fail (task->session_token, -1);

    if (!task->is_clone) {
        master = seaf_branch_manager_get_branch (seaf->branch_mgr,
                                                 task->repo_id,
                                                 "master");
        if (master != NULL)
            end_commit_id = master->commit_id;
    }

    /* fs_roots can be non-NULL if transfer is resumed from NET_DOWN. */
    if (task->fs_roots != NULL)
        object_list_free (task->fs_roots);
    task->fs_roots = object_list_new ();

    if (end_commit_id != NULL)
        g_string_printf (buf, "remote %s seafile-putcommit-v2 %s %s %s",
                         processor->peer_id, 
                         task->head, end_commit_id, task->session_token);
    else
        g_string_printf (buf, "remote %s seafile-putcommit-v2 %s %s",
                         processor->peer_id, 
                         task->head, task->session_token);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    seaf_branch_unref (master);

    return 0;
}
Esempio n. 14
0
static int
service_stub_start (CcnetProcessor *processor, int argc, char **argv)
{
    GString *buf;
    ServiceStubPriv *priv = GET_PRIV (processor);

    g_return_val_if_fail (priv->proxy_proc != NULL, -1);
    buf = g_string_new (NULL);

    CcnetProcessor *pproc = (CcnetProcessor *)priv->proxy_proc;
    if (!pproc->peer->is_local) {
        /* remote? (this may be wrong) */
        g_string_append (buf, "remote ");
        g_string_append (buf, pproc->peer->id);
        g_string_append (buf, " ");
    }

    strnjoin (argc, argv, buf);
    ccnet_processor_send_request (processor, buf->str);
    g_string_free (buf, TRUE);

    return 0;
}
Esempio n. 15
0
static void send_request(CcnetProcessor *processor)
{
    char buf[64];
    snprintf (buf, 64, "keepalive v%d", MY_VERSION);
    ccnet_processor_send_request (processor, buf);
}