Skip to content

Commit 90cf86e

Browse files
GustedGusted
authored andcommitted
CB/fix: Consider RepoPath symlinked for size calculation (!37)
- Currently Codeberg is manually symlinking specific `.git` repository to the Ceph file system. While Git seems to handle this correctly, Gitea's code doesn't take this into consideration. This patch will always check if the `.git` repository is symlinked and if it, return the correct folder(the one on Ceph storage). Co-authored-by: Gusted <[email protected]> Reviewed-on: https://codeberg.org/Codeberg/gitea/pulls/37 Co-authored-by: Gusted <[email protected]> Co-committed-by: Gusted <[email protected]>
1 parent 1f075eb commit 90cf86e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/repository/create.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"os"
1111
"path"
12+
"path/filepath"
1213
"strings"
1314
"unicode/utf8"
1415

@@ -142,7 +143,14 @@ func CreateRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (
142143

143144
// UpdateRepoSize updates the repository size, calculating it using util.GetDirectorySize
144145
func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
145-
size, err := util.GetDirectorySize(repo.RepoPath())
146+
// Figure out the real path by evaluating any possible symlink.
147+
path := repo.RepoPath()
148+
realPath, err := filepath.EvalSymlinks(path)
149+
if err == nil {
150+
path = realPath
151+
}
152+
153+
size, err := util.GetDirectorySize(path)
146154
if err != nil {
147155
return fmt.Errorf("updateSize: %v", err)
148156
}

0 commit comments

Comments
 (0)