Skip to content

Fix error when calculate the repository size #22392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug
  • Loading branch information
lunny committed Jan 13, 2023
commit 438fc931920f638ffc4259d99cbaeaa0de12e362
10 changes: 8 additions & 2 deletions modules/repository/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,20 @@ const notRegularFileMode os.FileMode = os.ModeSymlink | os.ModeNamedPipe | os.Mo
func getDirectorySize(path string) (int64, error) {
var size int64
err := filepath.WalkDir(path, func(_ string, info os.DirEntry, err error) error {
if os.IsNotExist(err) || info.IsDir() {
if err != nil {
if os.IsNotExist(err) { // ignore the error because the file maybe deleted during traversing.
return nil
}
return err
}
if info.IsDir() {
return nil
}
f, err := info.Info()
if err != nil {
return err
}
if info != nil && (f.Mode()&notRegularFileMode) == 0 {
if (f.Mode() & notRegularFileMode) == 0 {
size += f.Size()
}
return err
Expand Down