Skip to content

Commit

Permalink
Reduce writing the file or directory that does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev committed Dec 22, 2021
1 parent 872039a commit 0ad767c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion monitor/base_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/no-src/gofs/retry"
"github.com/no-src/gofs/sync"
"github.com/no-src/log"
"os"
"sort"
goSync "sync"
"time"
Expand Down Expand Up @@ -86,7 +87,13 @@ func (m *baseMonitor) startSyncWrite() {
name := <-m.writeChan
if m.retry != nil {
m.retry.Do(func() error {
return m.syncer.Write(name)
err := m.syncer.Write(name)
// if file or directory is not exist, ignore it and warning
if os.IsNotExist(err) {
log.Warn("write file failed => [%s]", err.Error())
return nil
}
return err
}, fmt.Sprintf("write file => %s", name))
} else {
if err := m.syncer.Write(name); err != nil {
Expand Down

0 comments on commit 0ad767c

Please sign in to comment.