Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try retrieving virus def files when non exist
Browse files Browse the repository at this point in the history
gmrabian committed Nov 15, 2023
1 parent f9eef52 commit a43c68c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions services/uploads/src/clamav.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ async function listBucketFiles(bucketName) {
});
try {
const listFilesResult = await S3.send(listObjects);
const keys = listFilesResult.Contents.map((c) => c.Key);
const keys = listFilesResult?.Contents?.map((c) => c.Key);
return keys;
} catch (err) {
utils.generateSystemMessage(`Error listing files`);
@@ -126,12 +126,11 @@ async function uploadAVDefinitions() {
utils.generateSystemMessage("Uploading Definitions");
const s3AllFullKeys = await listBucketFiles(constants.CLAMAV_BUCKET_NAME);

const s3DefinitionFileFullKeys = s3AllFullKeys.filter((key) =>
key.startsWith(constants.PATH_TO_AV_DEFINITIONS)
);

// If there are any s3 Definition files in the s3 bucket, delete them.
if (s3DefinitionFileFullKeys.length != 0) {
if (s3AllFullKeys?.length != 0) {
const s3DefinitionFileFullKeys = s3AllFullKeys.filter((key) =>
key.startsWith(constants.PATH_TO_AV_DEFINITIONS)
);
const deleteObject = new DeleteObjectsCommand({
Bucket: constants.CLAMAV_BUCKET_NAME,
Delete: {

0 comments on commit a43c68c

Please sign in to comment.