From 84477411f6ef4ac4eef09cc1050acdebb32d2ba7 Mon Sep 17 00:00:00 2001 From: feiniks <36756310+feiniks@users.noreply.github.com> Date: Sat, 21 Dec 2024 12:24:04 +0800 Subject: [PATCH] Check if dir is ignored and if file exists when record "index error" (#2863) * Check if dir is ignored and record index error when file exists * Check if file exists --------- Co-authored-by: yangheran --- daemon/repo-mgr.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/daemon/repo-mgr.c b/daemon/repo-mgr.c index 405ca52a..9cab850a 100644 --- a/daemon/repo-mgr.c +++ b/daemon/repo-mgr.c @@ -1756,8 +1756,11 @@ add_file (const char *repo_id, S_IFREG, SYNC_STATUS_ERROR, TRUE); - send_file_sync_error_notification (repo_id, NULL, path, - SYNC_ERROR_ID_INDEX_ERROR); + // Only record index error when the file exists. + if (seaf_util_exists (full_path)) { + send_file_sync_error_notification (repo_id, NULL, path, + SYNC_ERROR_ID_INDEX_ERROR); + } } return ret; @@ -1806,8 +1809,10 @@ add_dir_recursive (const char *path, const char *full_path, SeafStat *st, S_IFDIR, SYNC_STATUS_ERROR, TRUE); - send_file_sync_error_notification (params->repo_id, NULL, path, - SYNC_ERROR_ID_INDEX_ERROR); + if (!ignored) { + send_file_sync_error_notification (params->repo_id, NULL, path, + SYNC_ERROR_ID_INDEX_ERROR); + } return 0; } @@ -2144,8 +2149,10 @@ add_dir_recursive (const char *path, const char *full_path, SeafStat *st, S_IFDIR, SYNC_STATUS_ERROR, TRUE); - send_file_sync_error_notification (params->repo_id, NULL, path, - SYNC_ERROR_ID_INDEX_ERROR); + if (!ignored) { + send_file_sync_error_notification (params->repo_id, NULL, path, + SYNC_ERROR_ID_INDEX_ERROR); + } return 0; } @@ -2699,8 +2706,10 @@ add_remain_files (SeafRepo *repo, struct index_state *istate, S_IFREG, SYNC_STATUS_ERROR, TRUE); - send_file_sync_error_notification (repo->id, NULL, path, - SYNC_ERROR_ID_INDEX_ERROR); + if (seaf_util_exists (full_path)) { + send_file_sync_error_notification (repo->id, NULL, path, + SYNC_ERROR_ID_INDEX_ERROR); + } } } else if (S_ISDIR(st.st_mode)) { if (is_empty_dir (full_path, ignore_list)) {