-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent unnecessary operations on write actions to read-only reposito…
…ry in s3 gateway (#7844) * fail fast on write actions to read-only repository in s3 gateway add checks in put, delete and copy add tests make TestS3UploadToReadOnlyRepoError fail if the entire file was read * simplify test
- Loading branch information
1 parent
7559cd1
commit 2bbc93f
Showing
7 changed files
with
131 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package esti | ||
|
||
import "io" | ||
|
||
// ZeroReader reads only zeros into the provided buffer, until `Amount` is reached. | ||
type ZeroReader struct { | ||
Amount int | ||
NumBytesRead int | ||
} | ||
|
||
func NewZeroReader(amount int) *ZeroReader { | ||
return &ZeroReader{ | ||
Amount: amount, | ||
NumBytesRead: 0, | ||
} | ||
} | ||
|
||
func (zr *ZeroReader) Read(p []byte) (n int, err error) { | ||
if zr.NumBytesRead >= zr.Amount { | ||
return 0, io.EOF | ||
} | ||
n = len(p) | ||
if zr.NumBytesRead+n > zr.Amount { | ||
n = zr.Amount - zr.NumBytesRead | ||
} | ||
for i := 0; i < n; i++ { | ||
p[i] = 0 | ||
} | ||
zr.NumBytesRead += n | ||
return n, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters