Browse Source

Adding missing IsNotExist Function and proper Path Handling

tags/v1.2.0
Stefan Benten 4 years ago
parent
commit
7dc3982c77
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      server/storage.go

+ 9
- 4
server/storage.go View File

@@ -25,6 +25,7 @@ import (
"google.golang.org/api/googleapi"

"storj.io/storj/lib/uplink"
"storj.io/storj/pkg/storj"
)

type Storage interface {
@@ -616,7 +617,7 @@ func (s *StorjStorage) Type() string {
}

func (s *StorjStorage) Head(token string, filename string) (contentType string, contentLength uint64, err error) {
key := filepath.Join(token, filename)
key := storj.JoinPaths(token, filename)

ctx := context.TODO()

@@ -631,7 +632,7 @@ func (s *StorjStorage) Head(token string, filename string) (contentType string,
}

func (s *StorjStorage) Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error) {
key := filepath.Join(token, filename)
key := storj.JoinPaths(token, filename)

s.logger.Printf("Getting file %s from Storj Bucket", filename)

@@ -648,7 +649,7 @@ func (s *StorjStorage) Get(token string, filename string) (reader io.ReadCloser,
}

func (s *StorjStorage) Delete(token string, filename string) (err error) {
key := filepath.Join(token, filename)
key := storj.JoinPaths(token, filename)

s.logger.Printf("Deleting file %s from Storj Bucket", filename)

@@ -660,7 +661,7 @@ func (s *StorjStorage) Delete(token string, filename string) (err error) {
}

func (s *StorjStorage) Put(token string, filename string, reader io.Reader, contentType string, contentLength uint64) (err error) {
key := filepath.Join(token, filename)
key := storj.JoinPaths(token, filename)

s.logger.Printf("Uploading file %s to Storj Bucket", filename)

@@ -672,3 +673,7 @@ func (s *StorjStorage) Put(token string, filename string, reader io.Reader, cont
}
return nil
}

func (s *StorjStorage) IsNotExist(err error) bool {
return storj.ErrObjectNotFound.Has(err)
}

Loading…
Cancel
Save