diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2022-08-29 14:08:54 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-08-29 16:57:19 +0200 |
| commit | dbf801b93d8e458a32a8e88d2bdd8de447338bbf (patch) | |
| tree | 12d0c7cc4e8495bb97bda09619f4cef5581d8e31 | |
| parent | ba6652b6b4e6148d4ab8ba583f0a88a48293130f (diff) | |
pkg/asset: return the proper error when a GCS object exists
The caller expects a FileExistsError error.
| -rw-r--r-- | pkg/asset/backend_gcs.go | 4 | ||||
| -rw-r--r-- | pkg/asset/storage.go | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/pkg/asset/backend_gcs.go b/pkg/asset/backend_gcs.go index 3cbe445ee..6690ee3e9 100644 --- a/pkg/asset/backend_gcs.go +++ b/pkg/asset/backend_gcs.go @@ -62,10 +62,10 @@ func (csb *cloudStorageBackend) upload(req *uploadRequest) (*uploadResponse, err // complicated error-during-write handling. exists, err := csb.client.FileExists(path) if err != nil { - return nil, &FileExistsError{req.savePath} + return nil, err } if exists { - return nil, ErrAssetExists + return nil, &FileExistsError{req.savePath} } w, err := csb.client.FileWriterExt(path, req.contentType, req.contentEncoding) csb.tracer.Log("gcs upload: obtained a writer for %s, error %s", path, err) diff --git a/pkg/asset/storage.go b/pkg/asset/storage.go index 5c7134fd0..e790732bd 100644 --- a/pkg/asset/storage.go +++ b/pkg/asset/storage.go @@ -192,8 +192,6 @@ func (e *FileExistsError) Error() string { return fmt.Sprintf("asset exists: %s", e.Path) } -var ErrAssetExists = errors.New("the asset already exists") - const deletionEmbargo = time.Hour * 24 * 7 // Best way: convert download URLs to paths. |
