Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpert committed Sep 17, 2022
1 parent e43767c commit 801c0d9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,24 +294,6 @@ func (conn *SqliteStreamDB) RestoreFrom(bkFilePath string) error {
})
}

func copyFile(fromPath, toPath string) error {
fi, err := os.OpenFile(fromPath, os.O_RDWR, 0)
if err != nil {
return err
}
defer fi.Close()

fo, err := os.OpenFile(toPath, os.O_WRONLY, 0)
if err != nil {
return err
}
defer fo.Close()

bytesWritten, err := io.Copy(fo, fi)
log.Debug().Int64("bytes", bytesWritten).Msg("Backup bytes copied...")
return err
}

func (conn *SqliteStreamDB) GetRawConnection() *sqlite3.SQLiteConn {
return conn.rawConnection
}
Expand Down Expand Up @@ -360,3 +342,21 @@ func (e *ChangeLogEvent) Hash() (uint64, error) {

return hasher.Sum64(), nil
}

func copyFile(fromPath, toPath string) error {
fi, err := os.OpenFile(fromPath, os.O_RDWR, 0)
if err != nil {
return err
}
defer fi.Close()

fo, err := os.OpenFile(toPath, os.O_WRONLY|os.O_TRUNC, 0)
if err != nil {
return err
}
defer fo.Close()

bytesWritten, err := io.Copy(fo, fi)
log.Debug().Int64("bytes", bytesWritten).Msg("Backup bytes copied...")
return err
}

0 comments on commit 801c0d9

Please sign in to comment.