aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author65432022-06-18 18:36:39 +0200
committerGitHub2022-06-18 18:36:39 +0200
commitfe18cf7620442eb59ccad22f36a11aa6cd9a89bf (patch)
tree624d758f31e362951579ef34540ed0506ef8672e
parent7bfadb46ffd958b80b13f1a34824f68fab0167f4 (diff)
parent433443ffa9f41dbf548d1c63d3355221c6a63e9b (diff)
Merge branch 'main' into feature-activitypub
-rw-r--r--cmd/dump.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index ea41c0c02..d807cb058 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -22,7 +22,7 @@ import (
"code.gitea.io/gitea/modules/util"
"gitea.com/go-chi/session"
- archiver "github.com/mholt/archiver/v3"
+ "github.com/mholt/archiver/v3"
"github.com/urfave/cli"
)
@@ -439,8 +439,23 @@ func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeA
}
}
} else {
- if err = addFile(w, currentInsidePath, currentAbsPath, verbose); err != nil {
- return err
+ // only copy regular files and symlink regular files, skip non-regular files like socket/pipe/...
+ shouldAdd := file.Mode().IsRegular()
+ if !shouldAdd && file.Mode()&os.ModeSymlink == os.ModeSymlink {
+ target, err := filepath.EvalSymlinks(currentAbsPath)
+ if err != nil {
+ return err
+ }
+ targetStat, err := os.Stat(target)
+ if err != nil {
+ return err
+ }
+ shouldAdd = targetStat.Mode().IsRegular()
+ }
+ if shouldAdd {
+ if err = addFile(w, currentInsidePath, currentAbsPath, verbose); err != nil {
+ return err
+ }
}
}
}