Skip to content

Commit

Permalink
Don't fail on delete errros Just send a warning BNN-394 #resolve (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis-Cruz authored May 19, 2020
1 parent 1c7a99d commit 9b6914a
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.fenixedu.bennu.core.util.CoreConfiguration;
import org.fenixedu.jwt.Tools;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
Expand All @@ -20,6 +22,8 @@

public class DriveAPIStorage extends DriveAPIStorage_Base {

private static final Logger logger = LoggerFactory.getLogger(DriveAPIStorage.class.getName());

static {
Unirest.config().reset();
Unirest.config().followRedirects(false);
Expand Down Expand Up @@ -78,7 +82,15 @@ private boolean deleteFile(final String fileId) {
.header("Authorization", "Bearer " + getAccessToken())
.header("X-Requested-With", "XMLHttpRequest")
.asString();
return response.getStatus() == 204;
if (response.getStatus() != 204) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to delete file: " + fileId + ". Got response code: " + response.getStatus());
}
if (logger.isDebugEnabled()) {
logger.debug("Failed message:" + response.getBody());
}
}
return true;
}

private static String dirnameFor(final GenericFile file) {
Expand Down

0 comments on commit 9b6914a

Please sign in to comment.