[ 
https://issues.apache.org/jira/browse/SCB-255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332362#comment-16332362
 ] 

ASF GitHub Bot commented on SCB-255:
------------------------------------

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]


> Optimize log rotate lib
> -----------------------
>
>                 Key: SCB-255
>                 URL: https://issues.apache.org/jira/browse/SCB-255
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Service-Center
>            Reporter: little-cui
>            Assignee: little-cui
>            Priority: Major
>             Fix For: service-center-1.0.0-m1
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to