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

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

little-cui closed pull request #330: SCB-510 Expire backup log files are not 
removed
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/330
 
 
   

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/util/logrotate.go b/pkg/util/logrotate.go
index e7dbcefd..fe820afa 100644
--- a/pkg/util/logrotate.go
+++ b/pkg/util/logrotate.go
@@ -66,7 +66,7 @@ func removeExceededFiles(path string, baseFileName string,
        } else {
                return
        }
-       fileList, err := FilterFileList(path, pat)
+       fileList, err := FilterFileList(path, pat, 0777)
        if err != nil {
                Logger().Error("filepath.Walk() "+EscapPath(path)+" failed", 
err)
                return
@@ -176,7 +176,7 @@ func doBackup(fPath string, MaxBackupCount int) {
                return
        }
        pat := fmt.Sprintf(`%s\.[0-9]{1,17}$`, filepath.Base(fPath))
-       rotateFileList, err := FilterFileList(filepath.Dir(fPath), pat)
+       rotateFileList, err := FilterFileList(filepath.Dir(fPath), pat, 0777)
        if err != nil {
                Logger().Error("walk"+EscapPath(fPath)+" failed", err)
                return
@@ -229,7 +229,7 @@ func LogRotate(path string, MaxFileSize int, MaxBackupCount 
int) {
        }()
 
        pat := `.(\.log|\.trace|\.out)$`
-       fileList, err := FilterFileList(path, pat)
+       fileList, err := FilterFileList(path, pat, 0200)
        if err != nil {
                Logger().Error("filepath.Walk() "+EscapPath(path)+" failed", 
err)
                return
@@ -240,14 +240,15 @@ 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)
+func isSkip(f os.FileInfo, permits os.FileMode) bool {
+       //dir or permission deny
+       return f.IsDir() || (f.Mode()&permits == 0000)
 }
 
-//path : where the file will be filtered
-//pat  : regexp pattern to filter the matched file
-func FilterFileList(path, pat string) ([]string, error) {
+//path    : where the file will be filtered
+//pat     : regexp pattern to filter the matched file
+//permit  : check the file whether match any of the permits or not
+func FilterFileList(path, pat string, permits os.FileMode) ([]string, error) {
        capacity := 10
        //initialize a fileName slice, len=0, cap=10
        fileList := make([]string, 0, capacity)
@@ -257,7 +258,7 @@ func FilterFileList(path, pat string) ([]string, error) {
                        if f == nil {
                                return e
                        }
-                       if isSkip(f) {
+                       if isSkip(f, permits) {
                                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]


> Expire backup log files are not removed
> ---------------------------------------
>
>                 Key: SCB-510
>                 URL: https://issues.apache.org/jira/browse/SCB-510
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Service-Center
>            Reporter: little-cui
>            Assignee: little-cui
>            Priority: Major
>             Fix For: service-center-1.0.0-m2
>
>




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

Reply via email to