dashboard / erock/go-rsync-receiver / fix: close read readers #45 rss

accepted · opened on 2025-01-21T15:08:10Z by erock
Help
checkout latest patchset:
ssh pr.pico.sh print pr-45 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print ps-X | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 45
add review to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add --review 45
accept PR:
ssh pr.pico.sh pr accept 45
close PR:
ssh pr.pico.sh pr close 45

Logs

erock created pr with ps-96 on 2025-01-21T15:08:10Z
erock changed status on 2025-02-01T18:43:27Z {"status":"accepted"}

Patchsets

ps-96 by erock on 2025-01-21T15:08:10Z

Patchset ps-96

fix: close read readers

Eric Bower
2024-07-09T01:59:33Z
utils/fs.go
+6 -1
Back to top

fix: close read readers

rsyncsender/sender.go link
+1 -0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
diff --git a/rsyncsender/sender.go b/rsyncsender/sender.go
index 292b92a..5babaf1 100644
--- a/rsyncsender/sender.go
+++ b/rsyncsender/sender.go
@@ -141,6 +141,7 @@ func (st *sendTransfer) sendFile(fileIndex int32, fl *utils.SenderFile) error {
 	const chunkSize = 32 * 1024
 
 	fi, f, err := st.filesystem.Read(fl)
+	defer f.Close()
 	if err != nil {
 		return err
 	}
utils/fs.go link
+6 -1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/utils/fs.go b/utils/fs.go
index f129817..f446f81 100644
--- a/utils/fs.go
+++ b/utils/fs.go
@@ -5,10 +5,15 @@ import (
 	"os"
 )
 
+type ReaderAtCloser interface {
+	io.ReaderAt
+	io.Closer
+}
+
 // File System: need to handle all type of files: regular, folder, symlink, etc
 type FS interface {
 	Put(*ReceiverFile) (int64, error)
 	Skip(*ReceiverFile) bool
 	List(string) ([]os.FileInfo, error)
-	Read(*SenderFile) (os.FileInfo, io.ReaderAt, error)
+	Read(*SenderFile) (os.FileInfo, ReaderAtCloser, error)
 }