Skip to content

Commit

Permalink
🔊 chore: update log message for debug ci test error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 28, 2023
1 parent 81af6cd commit 2865e8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions rotatefile/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ func compressFile(srcPath, dstPath string) error {
defer srcFile.Close()

// create and open a gz file
gzFile, err := fsutil.QuickOpenFile(dstPath)
gzFile, err := fsutil.OpenTruncFile(dstPath)
if err != nil {
return err
}
defer gzFile.Close()

zw := gzip.NewWriter(gzFile)

fileSt, err := srcFile.Stat()
srcSt, err := srcFile.Stat()
if err != nil {
return err
}

zw.Name = fileSt.Name()
zw.ModTime = fileSt.ModTime()
zw := gzip.NewWriter(gzFile)
zw.Name = srcSt.Name()
zw.ModTime = srcSt.ModTime()

// do copy
if _, err = io.Copy(zw, srcFile); err != nil {
_ = zw.Close()
return err
}
return zw.Close()
Expand Down
6 changes: 3 additions & 3 deletions rotatefile/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (d *Writer) Clean() (err error) {

oldFiles = oldFiles[idx+1:]
if err != nil {
return err
return errorx.Wrap(err, "remove old file error")
}
}
}
Expand Down Expand Up @@ -427,9 +427,9 @@ func (d *Writer) compressFiles(oldFiles []fileInfo) error {
return errorx.Wrap(err, "compress old file error")
}

// remove raw log file
// remove old log file
if err = os.Remove(fi.filePath); err != nil {
return err
return errorx.Wrap(err, "remove file error after compress")
}
}
return nil
Expand Down

0 comments on commit 2865e8a

Please sign in to comment.