From a02b7ce21ee19094fb523c6acd078b149c09dbed Mon Sep 17 00:00:00 2001 From: JonRB Date: Sat, 29 Mar 2025 09:45:49 +0000 Subject: [PATCH 1/2] Use os.PathSeparator to correctly split per OS --- services/doctor/storage.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/doctor/storage.go b/services/doctor/storage.go index 3f3b562c370c7..4ab8aa135ef1f 100644 --- a/services/doctor/storage.go +++ b/services/doctor/storage.go @@ -7,6 +7,7 @@ import ( "context" "errors" "io/fs" + "os" "strings" "code.gitea.io/gitea/models/git" @@ -121,7 +122,7 @@ func checkStorage(opts *checkStorageOptions) func(ctx context.Context, logger lo storer: storage.LFS, isOrphaned: func(path string, obj storage.Object, stat fs.FileInfo) (bool, error) { // The oid of an LFS stored object is the name but with all the path.Separators removed - oid := strings.ReplaceAll(path, "/", "") + oid := strings.ReplaceAll(path, string(os.PathSeparator), "") exists, err := git.ExistsLFSObject(ctx, oid) return !exists, err }, From bb7014ac17ddc7d0dbf66f80929f5926dca1f479 Mon Sep 17 00:00:00 2001 From: JonRB Date: Sat, 29 Mar 2025 21:53:35 +0000 Subject: [PATCH 2/2] manage each separator uniquely --- services/doctor/storage.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/doctor/storage.go b/services/doctor/storage.go index 4ab8aa135ef1f..77fc6d65dfafc 100644 --- a/services/doctor/storage.go +++ b/services/doctor/storage.go @@ -7,7 +7,6 @@ import ( "context" "errors" "io/fs" - "os" "strings" "code.gitea.io/gitea/models/git" @@ -122,7 +121,7 @@ func checkStorage(opts *checkStorageOptions) func(ctx context.Context, logger lo storer: storage.LFS, isOrphaned: func(path string, obj storage.Object, stat fs.FileInfo) (bool, error) { // The oid of an LFS stored object is the name but with all the path.Separators removed - oid := strings.ReplaceAll(path, string(os.PathSeparator), "") + oid := strings.ReplaceAll(strings.ReplaceAll(path, "\\", ""), "/", "") exists, err := git.ExistsLFSObject(ctx, oid) return !exists, err },