Skip to content

Commit

Permalink
catch if we reach the action limit on blackbaze
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Sep 4, 2023
1 parent d6bd80e commit b3ef7ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions tests/functions/Util.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,21 @@ component {
}

public static boolean function isBackBlazeNotSupported() {
res= getBackBlazeCredentials();
return isNull(res) || len(res)==0;
if(!isNull(server.isBackBlazeNotSupported)) return server.isBackBlazeNotSupported;
var cred= getBackBlazeCredentials();
if(isNull(cred) || len(cred)==0) return true;
try {
S3Exists(bucketName:"test-is-supported", accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY, host:(isNull(cred.HOST)?nullvalue():cred.HOST));
}
catch(e) {
if(findNoCase("increase your cap", e.message)) {
server.isBackBlazeNotSupported=true;
return true;
}
}
return false;
}

public static struct function getBackBlazeCredentials() {
var ACCESS_KEY_ID=server.system.environment.S3_BACKBLAZE_ACCESS_KEY_ID?:nullValue();
if(isNull(ACCESS_KEY_ID) || isEmpty(ACCESS_KEY_ID)) return {};
Expand Down
16 changes: 14 additions & 2 deletions tests/tickets/Util.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,21 @@ component {
}

public static boolean function isBackBlazeNotSupported() {
res= getBackBlazeCredentials();
return isNull(res) || len(res)==0;
if(!isNull(server.isBackBlazeNotSupported)) return server.isBackBlazeNotSupported;
var cred= getBackBlazeCredentials();
if(isNull(cred) || len(cred)==0) return true;
try {
S3Exists(bucketName:"test-is-supported", accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY, host:(isNull(cred.HOST)?nullvalue():cred.HOST));
}
catch(e) {
if(findNoCase("increase your cap", e.message)) {
server.isBackBlazeNotSupported=true;
return true;
}
}
return false;
}

public static struct function getBackBlazeCredentials() {
var ACCESS_KEY_ID=server.system.environment.S3_BACKBLAZE_ACCESS_KEY_ID?:nullValue();
if(isNull(ACCESS_KEY_ID) || isEmpty(ACCESS_KEY_ID)) return {};
Expand Down

0 comments on commit b3ef7ee

Please sign in to comment.