Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit c521ed0

Browse files
authored
feat: Add support for Write Empty File Behavior (#54)
1 parent 57543d3 commit c521ed0

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-pipeline-go v0.2.3
77
github.com/Azure/azure-storage-blob-go v0.14.0
88
github.com/beyondstorage/go-endpoint v1.1.0
9-
github.com/beyondstorage/go-integration-test/v4 v4.4.0
9+
github.com/beyondstorage/go-integration-test/v4 v4.5.0
1010
github.com/beyondstorage/go-storage/v4 v4.7.0
1111
github.com/google/uuid v1.3.0
1212
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/Xuanwo/templateutils v0.1.0 h1:WpkWOqQtIQ2vAIpJLa727DdN8WtxhUkkbDGa6U
1818
github.com/Xuanwo/templateutils v0.1.0/go.mod h1:OdE0DJ+CJxDBq6psX5DPV+gOZi8bhuHuVUpPCG++Wb8=
1919
github.com/beyondstorage/go-endpoint v1.1.0 h1:cpjmQdrAMyaLoT161NIFU/eXcsuMI3xViycid5/mBZg=
2020
github.com/beyondstorage/go-endpoint v1.1.0/go.mod h1:P2hknaGrziOJJKySv/XnAiVw/d3v12/LZu2gSxEx4nM=
21-
github.com/beyondstorage/go-integration-test/v4 v4.4.0 h1:wiItWmhoAY71Fp76u6u95jJn5m6swM9N/xNV9mW7nyI=
22-
github.com/beyondstorage/go-integration-test/v4 v4.4.0/go.mod h1:o0pHhyaRR/OO6QxnRqWW3aFjTycBZjoKSdHKN/JZRjo=
21+
github.com/beyondstorage/go-integration-test/v4 v4.5.0 h1:PMrB+aWd6yNwlrJSJOjqNLJtujsKderoSkG9/QOEQr0=
22+
github.com/beyondstorage/go-integration-test/v4 v4.5.0/go.mod h1:o0pHhyaRR/OO6QxnRqWW3aFjTycBZjoKSdHKN/JZRjo=
2323
github.com/beyondstorage/go-storage/v4 v4.7.0 h1:7hpRFNoPY0vWRSH/p2biD2dUQdZMrs1TuIkkqDefmCE=
2424
github.com/beyondstorage/go-storage/v4 v4.7.0/go.mod h1:mc9VzBImjXDg1/1sLfta2MJH79elfM6m47ZZvZ+q/Uw=
2525
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY=

storage.go

+8
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ func (s *Storage) write(ctx context.Context, path string, r io.Reader, size int6
343343
return
344344
}
345345

346+
// According to GSP-751, we should allow the user to pass in a nil io.Reader.
347+
// ref: https://github.com/beyondstorage/go-storage/blob/master/docs/rfcs/751-write-empty-file-behavior.md
348+
if r == nil && size != 0 {
349+
return 0, fmt.Errorf("reader is nil but size is not 0")
350+
} else {
351+
r = io.LimitReader(r, size)
352+
}
353+
346354
rp := s.getAbsPath(path)
347355

348356
if opt.HasIoCallback {

0 commit comments

Comments
 (0)