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:
@@ -577,7 +577,7 @@ func GetSeafdirByPath(repoID string, rootID string, path string) (*SeafDir, erro
|
|||||||
func GetSeafdirIDByPath(repoID, rootID, path string) (string, error) {
|
func GetSeafdirIDByPath(repoID, rootID, path string) (string, error) {
|
||||||
dirID, mode, err := GetObjIDByPath(repoID, rootID, path)
|
dirID, mode, err := GetObjIDByPath(repoID, rootID, path)
|
||||||
if err != nil {
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
if dirID == "" || !IsDir(mode) {
|
if dirID == "" || !IsDir(mode) {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -35,7 +36,10 @@ func mergeVirtualRepo(args ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if virtual {
|
if virtual {
|
||||||
mergeRepo(repoID)
|
err := mergeRepo(repoID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
go updateSizePool.AddTask(repoID)
|
go updateSizePool.AddTask(repoID)
|
||||||
|
|
||||||
@@ -52,7 +56,10 @@ func mergeVirtualRepo(args ...string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeRepo(id)
|
err := mergeRepo(id)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go updateSizePool.AddTask(repoID)
|
go updateSizePool.AddTask(repoID)
|
||||||
@@ -88,7 +95,11 @@ func mergeRepo(repoID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var origRoot string
|
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 == "" {
|
if origRoot == "" {
|
||||||
newPath, _ := handleMissingVirtualRepo(origRepo, origHead, vInfo)
|
newPath, _ := handleMissingVirtualRepo(origRepo, origHead, vInfo)
|
||||||
if newPath != "" {
|
if newPath != "" {
|
||||||
|
@@ -793,6 +793,7 @@ static void *merge_virtual_repo (void *vtask)
|
|||||||
char *root = NULL, *orig_root = NULL, *base_root = NULL;
|
char *root = NULL, *orig_root = NULL, *base_root = NULL;
|
||||||
char new_base_commit[41] = {0};
|
char new_base_commit[41] = {0};
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
/* repos */
|
/* repos */
|
||||||
repo = seaf_repo_manager_get_repo (mgr, repo_id);
|
repo = seaf_repo_manager_get_repo (mgr, repo_id);
|
||||||
@@ -837,7 +838,15 @@ static void *merge_virtual_repo (void *vtask)
|
|||||||
orig_repo->version,
|
orig_repo->version,
|
||||||
orig_head->root_id,
|
orig_head->root_id,
|
||||||
vinfo->path,
|
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) {
|
if (!orig_root) {
|
||||||
seaf_debug("Path %s not found in origin repo %.8s, delete or rename virtual repo %.8s\n",
|
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);
|
vinfo->path, vinfo->origin_repo_id, repo_id);
|
||||||
@@ -997,6 +1006,8 @@ static void *merge_virtual_repo (void *vtask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (error)
|
||||||
|
g_clear_error (&error);
|
||||||
seaf_repo_unref (repo);
|
seaf_repo_unref (repo);
|
||||||
seaf_repo_unref (orig_repo);
|
seaf_repo_unref (orig_repo);
|
||||||
seaf_commit_unref (head);
|
seaf_commit_unref (head);
|
||||||
|
Reference in New Issue
Block a user