mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-09 04:17:30 +08:00
[client] Fix conflict handling bug in clone.
A conflict file cannot be produced.
This commit is contained in:
parent
37bf2a3a7f
commit
9838f69417
@ -234,7 +234,8 @@ seaf_fs_manager_checkout_file (SeafFSManager *mgr,
|
||||
const char *in_repo_path,
|
||||
const char *conflict_head_id,
|
||||
gboolean force_conflict,
|
||||
gboolean *conflicted)
|
||||
gboolean *conflicted,
|
||||
const char *email)
|
||||
{
|
||||
Seafile *seafile;
|
||||
char *blk_id;
|
||||
@ -273,11 +274,26 @@ seaf_fs_manager_checkout_file (SeafFSManager *mgr,
|
||||
if (force_conflict || seaf_util_rename (tmp_path, file_path) < 0) {
|
||||
*conflicted = TRUE;
|
||||
|
||||
SeafRepo *repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
|
||||
if (!repo)
|
||||
goto bad;
|
||||
/* XXX
|
||||
* In new syncing protocol and http sync, files are checked out before
|
||||
* the repo is created. So we can't get user email from repo at this point.
|
||||
* So a email parameter is needed.
|
||||
* For old syncing protocol, repo always exists when files are checked out.
|
||||
* This is a quick and dirty hack. A cleaner solution should modifiy the
|
||||
* code of old syncing protocol to pass in email too. But I don't want to
|
||||
* spend more time on the nearly obsoleted code.
|
||||
*/
|
||||
const char *suffix = NULL;
|
||||
if (email) {
|
||||
suffix = email;
|
||||
} else {
|
||||
SeafRepo *repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
|
||||
if (!repo)
|
||||
goto bad;
|
||||
suffix = email;
|
||||
}
|
||||
|
||||
conflict_path = gen_conflict_path (file_path, repo->email, (gint64)time(NULL));
|
||||
conflict_path = gen_conflict_path (file_path, suffix, (gint64)time(NULL));
|
||||
|
||||
seaf_warning ("Cannot update %s, creating conflict file %s.\n",
|
||||
file_path, conflict_path);
|
||||
|
@ -179,7 +179,8 @@ seaf_fs_manager_checkout_file (SeafFSManager *mgr,
|
||||
const char *in_repo_path,
|
||||
const char *conflict_head_id,
|
||||
gboolean force_conflict,
|
||||
gboolean *conflicted);
|
||||
gboolean *conflicted,
|
||||
const char *email);
|
||||
|
||||
#endif /* not SEAFILE_SERVER */
|
||||
|
||||
|
@ -782,6 +782,7 @@ add_transfer_task (CloneTask *task, GError **error)
|
||||
task->server_side_merge,
|
||||
task->passwd,
|
||||
task->worktree,
|
||||
task->email,
|
||||
error);
|
||||
if (!task->tx_id)
|
||||
return -1;
|
||||
@ -796,6 +797,7 @@ add_transfer_task (CloneTask *task, GError **error)
|
||||
task->passwd,
|
||||
task->worktree,
|
||||
task->http_protocol_version,
|
||||
task->email,
|
||||
error);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
@ -108,6 +108,7 @@ http_tx_task_free (HttpTxTask *task)
|
||||
g_free (task->token);
|
||||
g_free (task->passwd);
|
||||
g_free (task->worktree);
|
||||
g_free (task->email);
|
||||
g_free (task);
|
||||
}
|
||||
|
||||
@ -2464,12 +2465,13 @@ http_tx_manager_add_download (HttpTxManager *manager,
|
||||
const char *passwd,
|
||||
const char *worktree,
|
||||
int protocol_version,
|
||||
const char *email,
|
||||
GError **error)
|
||||
{
|
||||
HttpTxTask *task;
|
||||
SeafRepo *repo;
|
||||
|
||||
if (!repo_id || !token || !host || !server_head_id) {
|
||||
if (!repo_id || !token || !host || !server_head_id || !email) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty argument(s)");
|
||||
return -1;
|
||||
}
|
||||
@ -2490,6 +2492,7 @@ http_tx_manager_add_download (HttpTxManager *manager,
|
||||
|
||||
memcpy (task->head, server_head_id, 40);
|
||||
task->protocol_version = protocol_version;
|
||||
task->email = g_strdup(email);
|
||||
|
||||
task->state = TASK_STATE_NORMAL;
|
||||
|
||||
|
@ -68,6 +68,7 @@ struct _HttpTxTask {
|
||||
int type;
|
||||
char *host;
|
||||
gboolean is_clone;
|
||||
char *email;
|
||||
|
||||
char head[41];
|
||||
|
||||
@ -107,6 +108,7 @@ http_tx_manager_add_download (HttpTxManager *manager,
|
||||
const char *passwd,
|
||||
const char *worktree,
|
||||
int protocol_version,
|
||||
const char *email,
|
||||
GError **error);
|
||||
|
||||
int
|
||||
|
@ -590,7 +590,8 @@ static int update_file_flags(struct merge_options *o,
|
||||
o->remote_head,
|
||||
path,
|
||||
FALSE,
|
||||
&conflicted) < 0) {
|
||||
&conflicted,
|
||||
NULL) < 0) {
|
||||
g_warning("Failed to checkout file %s.\n", file_id);
|
||||
refresh = 0;
|
||||
goto update_cache;
|
||||
|
@ -3069,7 +3069,8 @@ checkout_file (const char *repo_id,
|
||||
name,
|
||||
conflict_head_id,
|
||||
force_conflict,
|
||||
&conflicted) < 0) {
|
||||
&conflicted,
|
||||
is_http ? http_task->email : task->email) < 0) {
|
||||
seaf_warning ("Failed to checkout file %s.\n", path);
|
||||
g_free (path);
|
||||
return FETCH_CHECKOUT_FAILED;
|
||||
|
@ -729,6 +729,7 @@ start_fetch_if_necessary (SyncTask *task, const char *remote_head)
|
||||
task->server_side_merge,
|
||||
NULL,
|
||||
NULL,
|
||||
repo->email,
|
||||
&error);
|
||||
|
||||
if (error != NULL) {
|
||||
@ -748,6 +749,7 @@ start_fetch_if_necessary (SyncTask *task, const char *remote_head)
|
||||
FALSE,
|
||||
NULL, NULL,
|
||||
task->http_version,
|
||||
repo->email,
|
||||
&error) < 0) {
|
||||
seaf_warning ("Failed to start http download: %s.\n", error->message);
|
||||
seaf_sync_manager_set_task_error (task, SYNC_ERROR_START_FETCH);
|
||||
@ -2172,7 +2174,8 @@ handle_locked_file_update (SeafRepo *repo, struct index_state *istate,
|
||||
path,
|
||||
master->commit_id,
|
||||
force_conflict,
|
||||
&conflicted) < 0) {
|
||||
&conflicted,
|
||||
repo->email) < 0) {
|
||||
seaf_warning ("Failed to checkout previously locked file %s in repo "
|
||||
"%s(%.8s).\n",
|
||||
path, repo->name, repo->id);
|
||||
|
@ -242,6 +242,7 @@ seaf_transfer_task_free (TransferTask *task)
|
||||
g_free (task->from_branch);
|
||||
g_free (task->to_branch);
|
||||
g_free (task->token);
|
||||
g_free (task->email);
|
||||
|
||||
if (task->fs_roots)
|
||||
object_list_free (task->fs_roots);
|
||||
@ -585,11 +586,12 @@ seaf_transfer_manager_add_download (SeafTransferManager *manager,
|
||||
gboolean server_side_merge,
|
||||
const char *passwd,
|
||||
const char *worktree,
|
||||
const char *email,
|
||||
GError **error)
|
||||
{
|
||||
TransferTask *task;
|
||||
|
||||
if (!repo_id || !from_branch || !to_branch || !token) {
|
||||
if (!repo_id || !from_branch || !to_branch || !token || !email) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Empty argument(s)");
|
||||
return NULL;
|
||||
}
|
||||
@ -605,6 +607,7 @@ seaf_transfer_manager_add_download (SeafTransferManager *manager,
|
||||
TASK_TYPE_DOWNLOAD);
|
||||
task->state = TASK_STATE_NORMAL;
|
||||
task->repo_version = repo_version;
|
||||
task->email = g_strdup(email);
|
||||
|
||||
task->server_side_merge = server_side_merge;
|
||||
|
||||
|
@ -141,6 +141,7 @@ struct _TransferTask {
|
||||
int last_runtime_state;
|
||||
int type;
|
||||
gboolean is_clone; /* TRUE when fetching a new repo. */
|
||||
char *email;
|
||||
int error;
|
||||
|
||||
char *dest_id;
|
||||
@ -231,6 +232,7 @@ seaf_transfer_manager_add_download (SeafTransferManager *manager,
|
||||
gboolean server_side_merge,
|
||||
const char *passwd,
|
||||
const char *worktree,
|
||||
const char *email,
|
||||
GError **error);
|
||||
|
||||
char *
|
||||
|
@ -795,7 +795,8 @@ checkout_entry (struct cache_entry *ce,
|
||||
ce->name,
|
||||
conflict_head_id,
|
||||
force_conflict,
|
||||
&conflicted) < 0) {
|
||||
&conflicted,
|
||||
NULL) < 0) {
|
||||
g_warning ("Failed to checkout file %s.\n", path);
|
||||
g_free (path);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user