Remove tmp files on start up

This commit is contained in:
Ben Johnson
2020-12-24 16:42:45 -07:00
parent 87c8cea851
commit 89fd441e9a
3 changed files with 25 additions and 0 deletions

View File

@@ -92,6 +92,11 @@ func (r *FileReplicator) Stop() {
// monitor runs in a separate goroutine and continuously replicates the DB.
func (r *FileReplicator) monitor(ctx context.Context) {
// Clear old temporary files that my have been left from a crash.
if err := removeTmpFiles(r.dst); err != nil {
log.Printf("%s(%s): cannot remove tmp files: %w", r.db.Path(), r.Name(), err)
}
// Continuously check for new data to replicate.
ch := make(chan struct{})
close(ch)