Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Nov 3, 2023
1 parent 2bcc7d0 commit 7f88ea6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
8 changes: 6 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ function checkConnections() {
state.connections.data = results;
state.ready = Object.values(state.connections).every(x => x);
if (!wasReady && state.ready) log.info('Application ready to accept traffic', { function: 'checkConnections' });
if (wasReady && !state.ready) log.warn('Application not ready to accept traffic', { function: 'checkConnections' });
if (wasReady && !state.ready) log.warn('Application not ready to accept traffic', {
function: 'checkConnections'
});
log.silly('App state', { function: 'checkConnections', state: state });
if (!state.ready) notReadyHandler();
});
Expand Down Expand Up @@ -205,7 +207,9 @@ function initializeConnections() {
}
})
.catch(error => {
log.error(`Initialization failed: Database OK = ${state.connections.data}`, { function: 'initializeConnections' });
log.error(`Initialization failed: Database OK = ${state.connections.data}`, {
function: 'initializeConnections'
});
log.error('Connection initialization failure', error.message, { function: 'initializeConnections' });
if (!state.ready) notReadyHandler();
})
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ if (config.has('server.logFile')) {
/**
* Returns a Winston Logger or Child Winston Logger
* @param {string} [filename] Optional module filename path to annotate logs with
* @returns {object} A child logger with appropriate metadata if `filename` is defined. Otherwise returns a standard logger.
* @returns {object} A child logger with appropriate metadata if `filename` is defined.
* Otherwise returns a standard logger.
*/
const getLogger = (filename) => {
return filename ? log.child({ component: parse(filename).name }) : log;
Expand Down
18 changes: 15 additions & 3 deletions app/src/components/queueManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,30 @@ class QueueManager {

const objectId = await syncService.syncJob(job.path, job.bucketId, job.full, job.createdBy);

log.verbose(`Finished processing job id ${job.id}`, { function: 'processNextJob', job: job, objectId: objectId });
log.verbose(`Finished processing job id ${job.id}`, {
function: 'processNextJob',
job: job,
objectId: objectId
});

this.isBusy = false;
// If job is completed, check if there are more jobs
if (!this.toClose) this.checkQueue();
}
} catch (err) {
log.error(`Error encountered on job id ${job.id}: ${err.message}`, { function: 'processNextJob', job: job, error: err });
log.error(`Error encountered on job id ${job.id}: ${err.message}`, {
function: 'processNextJob',
job: job,
error: err
});

const maxRetries = parseInt(config.get('server.maxRetries'));
if (job.retries + 1 > maxRetries) {
log.warn(`Job has exceeded the ${maxRetries} maximum retries permitted`, { function: 'processNextJob', job: job, maxRetries: maxRetries });
log.warn(`Job has exceeded the ${maxRetries} maximum retries permitted`, {
function: 'processNextJob',
job: job,
maxRetries: maxRetries
});
} else {
objectQueueService.enqueue({
jobs: [{ bucketId: job.bucketId, path: job.path }],
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const utils = {
*/
addDashesToUuid(str) {
if ((typeof str === 'string' || str instanceof String) && str.length === 32) {
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`.toLowerCase();
return `${str.slice(0, 8)}-${str.slice(8, 12)}-${str.slice(12, 16)}-${str.slice(16, 20)}-${str.slice(20)}`
.toLowerCase();
}
else return str;
},
Expand Down
6 changes: 5 additions & 1 deletion app/src/controllers/bucketPermission.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ const controller = {
async addPermissions(req, res, next) {
try {
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, SYSTEM_USER));
const response = await bucketPermissionService.addPermissions(addDashesToUuid(req.params.bucketId), req.body, userId);
const response = await bucketPermissionService.addPermissions(
addDashesToUuid(req.params.bucketId),
req.body,
userId
);
res.status(201).json(response);
} catch (e) {
next(errorToProblem(SERVICE, e));
Expand Down
12 changes: 10 additions & 2 deletions app/src/controllers/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const controller = {
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, SYSTEM_USER));

// get source S3 VersionId
const sourceS3VersionId = await getS3VersionId(req.query.s3VersionId, addDashesToUuid(req.query.versionId), objId);
const sourceS3VersionId = await getS3VersionId(
req.query.s3VersionId,
addDashesToUuid(req.query.versionId),
objId
);

// get version from S3
const source = await storageService.headObject({
Expand All @@ -115,7 +119,11 @@ const controller = {
throw new Error('Cannot copy an object larger than 5GB');
}
// get existing tags on source object, eg: { 'animal': 'bear', colour': 'black' }
const sourceObject = await storageService.getObjectTagging({ filePath: objPath, s3VersionId: sourceS3VersionId, bucketId: bucketId });
const sourceObject = await storageService.getObjectTagging({
filePath: objPath,
s3VersionId: sourceS3VersionId,
bucketId: bucketId
});
const sourceTags = Object.assign({},
...(sourceObject.TagSet?.map(item => ({ [item.Key]: item.Value })) ?? [])
);
Expand Down
9 changes: 7 additions & 2 deletions app/src/services/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,13 @@ const service = {

// get VersionId of latest version in S3
const object = await objectService.read(objectId, trx);
const s3Versions = await storageService.listAllObjectVersions({ filePath: object.path, bucketId: object.bucketId });
const latestS3VersionId = s3Versions.DeleteMarkers.concat(s3Versions.Versions).filter((v) => v.IsLatest)[0].VersionId;
const s3Versions = await storageService.listAllObjectVersions({
filePath: object.path,
bucketId: object.bucketId
});
const latestS3VersionId = s3Versions.DeleteMarkers
.concat(s3Versions.Versions)
.filter((v) => v.IsLatest)[0].VersionId;

// get same version from COMS db
const current = await Version.query(trx)
Expand Down

0 comments on commit 7f88ea6

Please sign in to comment.