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
Show file tree
Hide file tree
Changes from all commits
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_CHECKOUT_FILE);
}
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
5 changes: 5 additions & 0 deletions daemon/seafile-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static SyncErrorInfo sync_error_info_tbl[] = {
SYNC_ERROR_LEVEL_REPO,
"Too many files in library"
},
{
SYNC_ERROR_ID_CHECKOUT_FILE,
SYNC_ERROR_LEVEL_FILE,
"Failed to checkout file on the client. Please check disk space or folder permissions"
},
};

const char *
Expand Down
3 changes: 2 additions & 1 deletion include/seafile-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#define SYNC_ERROR_ID_LIBRARY_TOO_LARGE 32
#define SYNC_ERROR_ID_DEL_CONFIRMATION_PENDING 33
#define SYNC_ERROR_ID_TOO_MANY_FILES 34
#define N_SYNC_ERROR_ID 35
#define SYNC_ERROR_ID_CHECKOUT_FILE 35
#define N_SYNC_ERROR_ID 36

#endif