Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a file-level error when failed to checkout file #2692

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions daemon/repo-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5090,6 +5090,19 @@ 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 @@ -5115,6 +5128,9 @@ 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);

finished_tasks = g_async_queue_new ();

Expand Down Expand Up @@ -5183,6 +5199,11 @@ download_files_http (const char *repo_id,
conflict_hash, no_conflict_hash,
conflict_head_id, fset);

// 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_WRITE_LOCAL_DATA);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYNC_ERROR_ID_WRITE_LOCAL_DATA 是一个现有的错误 ID,而且是一个资料库级别的错误。应该新定义一个文件级别的错误,专门用于导出文件失败。

}
if (!http_task->is_clone) {
SyncStatus status;
if (rc == FETCH_CHECKOUT_FAILED)
Expand Down Expand Up @@ -5230,6 +5251,7 @@ 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