Skip to content

Commit

Permalink
Only record a file-level error,don't send notification (#2701)
Browse files Browse the repository at this point in the history
* Only record a file-level error,don't send notification

* only send notification once

---------

Co-authored-by: heran yang <heran.yang@seafile.com>
  • Loading branch information
feiniks and heran yang authored Aug 28, 2023
1 parent 98b5288 commit 8ac92a6
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions daemon/repo-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5090,19 +5090,6 @@ handle_dir_added_de (const char *repo_id,
ce->ce_mtime.sec = de->mtime;
}

static char *
get_repo_name_from_commit (const char *repo_id, int repo_version, const char *commit_id)
{
SeafCommit *commit = seaf_commit_manager_get_commit (seaf->commit_mgr,
repo_id,
repo_version,
commit_id);
if (!commit)
return NULL;

return g_strdup(commit->repo_name);
}

#define DEFAULT_DOWNLOAD_THREADS 3

static int
Expand All @@ -5128,9 +5115,7 @@ download_files_http (const char *repo_id,
GList *ptr;
FileTxTask *task;
int ret = FETCH_CHECKOUT_SUCCESS;
char *repo_name = NULL;

repo_name = get_repo_name_from_commit (repo_id, repo_version, conflict_head_id);
gboolean checkout_file_failed = FALSE;

finished_tasks = g_async_queue_new ();

Expand Down Expand Up @@ -5201,9 +5186,16 @@ download_files_http (const char *repo_id,

// Record a file-level sync error when failed to checkout file.
if (rc == FETCH_CHECKOUT_FAILED) {
send_file_sync_error_notification (repo_id, repo_name, de->name,
SYNC_ERROR_ID_CHECKOUT_FILE);
if (checkout_file_failed) {
seaf_repo_manager_record_sync_error (repo_id, http_task->repo_name, de->name,
SYNC_ERROR_ID_CHECKOUT_FILE);
} else {
checkout_file_failed = TRUE;
send_file_sync_error_notification (repo_id, http_task->repo_name, de->name,
SYNC_ERROR_ID_CHECKOUT_FILE);
}
}

if (!http_task->is_clone) {
SyncStatus status;
if (rc == FETCH_CHECKOUT_FAILED)
Expand Down Expand Up @@ -5251,7 +5243,6 @@ download_files_http (const char *repo_id,
update_index (istate, index_path);

out:
g_free (repo_name);
/* Wait until all threads exit.
* This is necessary when the download is canceled or encountered error.
*/
Expand Down

0 comments on commit 8ac92a6

Please sign in to comment.