Improved notifications

Added progress indicator in clone output
This commit is contained in:
mitch 2021-12-31 02:17:42 -05:00
parent e77ab09050
commit 624c112176
2 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,7 @@ package main
*/ */
import ( import (
"fmt"
"io" "io"
"os" "os"
) )
@ -31,7 +32,7 @@ func clone(cloneBs int, cloneSource string, cloneTarget string) {
} }
defer fTarget.Close() defer fTarget.Close()
errorHandler(err) errorHandler(err)
//todo progress indicator progress := cloneBs
for { for {
n, err := fSource.Read(p) n, err := fSource.Read(p)
if err == io.EOF { if err == io.EOF {
@ -42,6 +43,9 @@ func clone(cloneBs int, cloneSource string, cloneTarget string) {
errorHandler(err) errorHandler(err)
_, err = fTarget.Write(p[:n]) _, err = fTarget.Write(p[:n])
errorHandler(err) errorHandler(err)
fmt.Println(progress/1048576, "MB written...")
progress += cloneBs
} }
fmt.Println("Performing sync operations...")
fTarget.Sync() fTarget.Sync()
} }

View File

@ -70,6 +70,7 @@ func writeToDisk(wipeDisk string, blocksize int, writeType string) {
} }
_, err = fTarget.Write(block[:n]) _, err = fTarget.Write(block[:n])
} }
fmt.Println("Performing sync operations...")
fTarget.Sync() fTarget.Sync()
} }