Skip to content

Commit

Permalink
Fix dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
triole committed Oct 9, 2023
1 parent 6b6111b commit a354cbf
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/logaxe/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,28 @@ func (la LogAxe) compressFile(sourceFile FileInfo, target tTarget) (err error) {
})

sourceFilesArr := []string{sourceFile.Path}
err = la.runCompression(sourceFilesArr, target, format)
end := time.Now()
elapsed := end.Sub(start)
if !la.DryRun {
err = la.runCompression(sourceFilesArr, target, format)
end := time.Now()
elapsed := end.Sub(start)

if err == nil {
taInfos := la.fileInfo(target.FullPath, time.Now())
la.Lg.Info(
"compression done",
logseal.F{
"file": target.FullPath, "duration": elapsed,
"size": taInfos.SizeHR,
},
)
} else {
la.Lg.Error(
"compression failed",
logseal.F{
"path": sourceFile.Path, "duration": elapsed, "error": err,
},
)
if err == nil {
taInfos := la.fileInfo(target.FullPath, time.Now())
la.Lg.Info(
"compression done",
logseal.F{
"file": target.FullPath, "duration": elapsed,
"size": taInfos.SizeHR,
},
)
} else {
la.Lg.Error(
"compression failed",
logseal.F{
"path": sourceFile.Path, "duration": elapsed, "error": err,
},
)
}
}
return
}
Expand Down

0 comments on commit a354cbf

Please sign in to comment.