feat: add compress command
This commit is contained in:
@@ -57,22 +57,23 @@ func Serve(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
log.Infof("start compressing %s", args[0])
|
||||
|
||||
if err := commandCompress(args[0]); err != nil {
|
||||
log.WithError(err).Errorf("compressing %s failed", args[0])
|
||||
return err
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(5 * time.Minute)
|
||||
for range ticker.C {
|
||||
failTimes := 0
|
||||
for {
|
||||
log.Infof("start compressing %s", args[0])
|
||||
|
||||
if err := commandCompress(args[0]); err != nil {
|
||||
log.WithError(err).Errorf("compressing %s failed", args[0])
|
||||
failTimes++
|
||||
|
||||
if failTimes >= 3 {
|
||||
return errors.New("failed to compress after 3 attempts")
|
||||
}
|
||||
continue
|
||||
}
|
||||
log.Infof("compressing %s done", args[0])
|
||||
|
||||
time.Sleep(5 * time.Minute)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func commandCompress(dir string) error {
|
||||
|
||||
Reference in New Issue
Block a user