1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-09-12 13:28:30 +00:00

Don't merge virtual repo when get a error which isn't path no exist (#548)

* Don't merge virtual repo when get a error which isn't path no exist

* Modify log info
This commit is contained in:
feiniks
2022-03-22 16:42:29 +08:00
committed by GitHub
parent 96b33251ce
commit c31e5dd25d
3 changed files with 27 additions and 5 deletions

View File

@@ -577,7 +577,7 @@ func GetSeafdirByPath(repoID string, rootID string, path string) (*SeafDir, erro
func GetSeafdirIDByPath(repoID, rootID, path string) (string, error) {
dirID, mode, err := GetObjIDByPath(repoID, rootID, path)
if err != nil {
err := fmt.Errorf("failed to get dir id by path: %s: %v", path, err)
err := fmt.Errorf("failed to get dir id by path: %s: %w", path, err)
return "", err
}
if dirID == "" || !IsDir(mode) {

View File

@@ -1,6 +1,7 @@
package main
import (
"errors"
"fmt"
"path/filepath"
"strings"
@@ -35,7 +36,10 @@ func mergeVirtualRepo(args ...string) error {
}
if virtual {
mergeRepo(repoID)
err := mergeRepo(repoID)
if err != nil {
log.Printf("%v", err)
}
go updateSizePool.AddTask(repoID)
@@ -52,7 +56,10 @@ func mergeVirtualRepo(args ...string) error {
continue
}
mergeRepo(id)
err := mergeRepo(id)
if err != nil {
log.Printf("%v", err)
}
}
go updateSizePool.AddTask(repoID)
@@ -88,7 +95,11 @@ func mergeRepo(repoID string) error {
}
var origRoot string
origRoot, _ = fsmgr.GetSeafdirIDByPath(origRepo.StoreID, origHead.RootID, vInfo.Path)
origRoot, err = fsmgr.GetSeafdirIDByPath(origRepo.StoreID, origHead.RootID, vInfo.Path)
if err != nil && !errors.Is(err, fsmgr.ErrPathNoExist) {
err := fmt.Errorf("failed to get seafdir id by path in origin repo %.10s: %v", origRepo.StoreID, err)
return err
}
if origRoot == "" {
newPath, _ := handleMissingVirtualRepo(origRepo, origHead, vInfo)
if newPath != "" {

View File

@@ -793,6 +793,7 @@ static void *merge_virtual_repo (void *vtask)
char *root = NULL, *orig_root = NULL, *base_root = NULL;
char new_base_commit[41] = {0};
int ret = 0;
GError *error = NULL;
/* repos */
repo = seaf_repo_manager_get_repo (mgr, repo_id);
@@ -837,7 +838,15 @@ static void *merge_virtual_repo (void *vtask)
orig_repo->version,
orig_head->root_id,
vinfo->path,
NULL);
&error);
if (error &&
!g_error_matches(error,
SEAFILE_DOMAIN,
SEAF_ERR_PATH_NO_EXIST)) {
seaf_warning ("Failed to get seafdir id by path in origin repo %.10s: %s.\n", orig_repo->store_id, error->message);
ret = -1;
goto out;
}
if (!orig_root) {
seaf_debug("Path %s not found in origin repo %.8s, delete or rename virtual repo %.8s\n",
vinfo->path, vinfo->origin_repo_id, repo_id);
@@ -997,6 +1006,8 @@ static void *merge_virtual_repo (void *vtask)
}
out:
if (error)
g_clear_error (&error);
seaf_repo_unref (repo);
seaf_repo_unref (orig_repo);
seaf_commit_unref (head);