diff --git a/src/main/java/gyro/google/GoogleStorageFileBackend.java b/src/main/java/gyro/google/GoogleStorageFileBackend.java index af9ae7e9..52882a89 100644 --- a/src/main/java/gyro/google/GoogleStorageFileBackend.java +++ b/src/main/java/gyro/google/GoogleStorageFileBackend.java @@ -21,12 +21,11 @@ import java.io.OutputStream; import java.util.stream.Stream; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.http.ByteArrayContent; import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.StorageObject; - import com.psddev.dari.util.ObjectUtils; - import gyro.core.FileBackend; import gyro.core.GyroException; import gyro.core.Type; @@ -94,7 +93,14 @@ public void close() { @Override public void delete(String file) throws Exception { - client().objects().delete(getBucket(), prefixed(file)).execute(); + // Delete if exists. + try { + client().objects().delete(getBucket(), prefixed(file)).execute(); + } catch (GoogleJsonResponseException e) { + if (e.getStatusCode() != 404) { + throw e; + } + } } private Storage client() {