little-cui closed pull request #250: SCB-255 logrotate bug fix ,non write
permission, skip
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/250
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pkg/logrotate/logrotate.go b/pkg/logrotate/logrotate.go
index d67b17ae..c2e9e93a 100644
--- a/pkg/logrotate/logrotate.go
+++ b/pkg/logrotate/logrotate.go
@@ -240,18 +240,24 @@ func LogRotate(path string, MaxFileSize int,
MaxBackupCount int) {
}
}
+func isSkip(f os.FileInfo) bool{
+ //dir or non write permission,skip
+ return f.IsDir() || (f.Mode() & 0200 == 0000)
+}
+
//path : where the file will be filtered
//pat : regexp pattern to filter the matched file
func FilterFileList(path, pat string) ([]string, error) {
capacity := 10
//initialize a fileName slice, len=0, cap=10
fileList := make([]string, 0, capacity)
+
err := filepath.Walk(path,
func(pathName string, f os.FileInfo, e error) error {
if f == nil {
return e
}
- if f.IsDir() {
+ if isSkip(f) {
return nil
}
if pat != "" {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services