Skip to content

Commit

Permalink
Fix writing an empty file or a same length file has no effect in the …
Browse files Browse the repository at this point in the history
…local disk mode
  • Loading branch information
mstmdev committed Mar 1, 2022
1 parent 994d7f2 commit 83826d2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sync/disk_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ func (s *diskSync) write(path, dest string) error {

sourceSize := sourceStat.Size()

if sourceSize == 0 {
log.Info("write to the dest file success [size=%d] [%s] -> [%s]", sourceSize, path, dest)
return nil
}

reader := bufio.NewReader(sourceFile)
writer := bufio.NewWriter(destFile)

Expand Down Expand Up @@ -200,6 +195,9 @@ func (s *diskSync) compare(sourceSize, destSize int64, sourceFile *os.File, dest
}

// reset the offset
if _, err = sourceFile.Seek(0, 0); err != nil {
return isSame, err
}
if _, err = destFile.Seek(0, 0); err != nil {
return isSame, err
}
Expand Down

0 comments on commit 83826d2

Please sign in to comment.