Skip to content

Commit bcfdf45

Browse files
committed
fix: Appending to a non-existent file should work
1 parent 1469bdf commit bcfdf45

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

registry/storage/driver/bunny/bunny.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ var _ storagedriver.StorageDriver = &driver{}
4949
type driver struct {
5050
pullZone url.URL
5151
client bunny.Client
52-
logger logrus.Logger
5352
}
5453

5554
// Delete implements driver.StorageDriver.
@@ -63,7 +62,6 @@ func (d *driver) Delete(ctx context.Context, path string) error {
6362

6463
// GetContent implements driver.StorageDriver.
6564
func (d *driver) GetContent(ctx context.Context, path string) ([]byte, error) {
66-
d.logger.WithField("path", path).Debug("Downloading content")
6765
return d.client.Download(path)
6866
}
6967

@@ -82,7 +80,6 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
8280

8381
// Move implements driver.StorageDriver.
8482
func (d *driver) Move(ctx context.Context, sourcePath string, destPath string) error {
85-
d.logger.WithField("sourcePath", sourcePath).WithField("destPath", destPath).Debug("Moving file")
8683
// Bunny Storage does not support moving files directly, so we need to download and re-upload.
8784
content, err := d.client.Download(sourcePath)
8885
if err != nil {
@@ -103,7 +100,6 @@ func (d *driver) PutContent(ctx context.Context, path string, content []byte) er
103100

104101
// Reader implements driver.StorageDriver.
105102
func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) {
106-
d.logger.WithField("path", path).WithField("offset", offset).Debug("Creating reader")
107103
return &bunnyFileReader{
108104
client: d.client,
109105
path: path,
@@ -146,9 +142,13 @@ func (d *driver) Writer(ctx context.Context, path string, append bool) (storaged
146142
if append {
147143
// Get the current file as the starting buffer
148144
content, err := d.client.Download(path)
149-
if err != nil {
145+
if err != nil && err.Error() != "Not Found" {
150146
return nil, err
151147
}
148+
if err != nil && err.Error() == "Not Found" {
149+
// If the file does not exist, we can start with an empty buffer
150+
content = []byte{}
151+
}
152152
return &BunnyFileWriter{
153153
client: d.client,
154154
path: path,

0 commit comments

Comments
 (0)