1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

fixed wrong file size when writing at dst

This commit is contained in:
postmannen 2022-06-15 20:55:20 +02:00
parent e010a1633a
commit 2d36e0195b

View file

@ -369,7 +369,7 @@ func copySrcSubProcFunc(proc process, cia copyInitialData) func(context.Context,
log.Printf(" * RECEIVED in copySrcSubProcFunc from dst * copyStatus=copyReady: %v\n\n", csa.CopyStatus)
b := make([]byte, cia.SplitChunkSize)
_, err := fh.Read(b)
n, err := fh.Read(b)
if err != nil && err != io.EOF {
log.Printf("error: copySrcSubHandler: failed to read chuck from file: %v\n", err)
}
@ -377,6 +377,14 @@ func copySrcSubProcFunc(proc process, cia copyInitialData) func(context.Context,
status = copyDone
}
// Testing here!
if n < cia.SplitChunkSize {
bb := make([]byte, n)
nr := copy(bb, b[:n])
b = bb
fmt.Printf(" ********************* DEBUG: copied %v elements, length of b=%v\n", nr, len(b))
}
lastReadChunk = b
// Create a hash of the bytes
@ -662,11 +670,19 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message) func
b := make([]byte, cia.SplitChunkSize)
_, err = fh.Read(b)
n, err := fh.Read(b)
if err != nil {
return err
}
// Testing here!
if n < cia.SplitChunkSize {
bb := make([]byte, n)
nr := copy(bb, b[:n])
b = bb
fmt.Printf(" ********************* DEBUG: copied %v elements, length of b=%v\n", nr, len(b))
}
fmt.Printf(" * DEBUG: read: %v\n", b)
_, err = mainfh.Write(b)