Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .mdeprc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module.exports = {
node: "14.15",
node: "14",
auto_compose: true,
with_local_compose: true,
sleep: 35,
services: ['rabbitmq'],
nycReport: false,
post_exec: 'yarn coverage:report'
post_exec: 'yarn coverage:report',
extras: {
rabbitmq: {

}
}
};

switch (process.env.DB) {
Expand Down
77 changes: 44 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,70 +33,81 @@
},
"homepage": "https://github.com/makeomatic/ms-files#readme",
"dependencies": {
"@google-cloud/storage": "5.7.3",
"@hapi/hapi": "^20.1.0",
"@hapi/joi": "^17.1.1",
"@microfleet/core": "^17.6.0",
"@microfleet/transport-amqp": "^15.2.3",
"@microfleet/validation": "9",
"@sentry/node": "^6.0.2",
"ali-oss": "^6.13.2",
"bl": "^4.0.3",
"@google-cloud/storage": "5.8.5",
"@hapi/hapi": "^20.1.2",
"@microfleet/core": "^17.5.4-next.57",
"@microfleet/plugin-amqp": "^0.0.0-next.590",
"@microfleet/plugin-dlock": "^0.0.0-next.57",
"@microfleet/plugin-hapi": "^0.0.0-next.590",
"@microfleet/plugin-logger": "^0.5.5-next.57",
"@microfleet/plugin-opentracing": "^0.0.1-next.590",
"@microfleet/plugin-prometheus": "^0.0.1-next.590",
"@microfleet/plugin-redis-cluster": "^0.0.1-next.590",
"@microfleet/plugin-redis-sentinel": "^0.0.1-next.590",
"@microfleet/plugin-router": "^0.0.0-next.590",
"@microfleet/plugin-router-amqp": "^0.0.0-next.590",
"@microfleet/plugin-router-hapi": "^0.0.0-next.590",
"@microfleet/plugin-validator": "^0.0.1-next.590",
"@microfleet/transport-amqp": "^15.2.6",
"@microfleet/validation": "^10.0.2",
"@sentry/node": "^6.2.5",
"ali-oss": "^6.15.2",
"bl": "^5.0.0",
"bluebird": "^3.7.2",
"cluster-key-slot": "^1.1.0",
"common-errors": "^1.2.0",
"dlock": "^12.1.1",
"flatstr": "^1.0.12",
"gcs-resumable-upload": "^3.1.2",
"ioredis": "4.19.4",
"gcs-resumable-upload": "^3.1.3",
"ioredis": "4.27.6",
"is": "^3.3.0",
"jaeger-client": "^3.18.1",
"lodash": "^4.17.20",
"joi": "^17.4.0",
"lodash": "^4.17.21",
"md5": "^2.3.0",
"mime-types": "^2.1.28",
"mime-types": "^2.1.30",
"moment": "^2.29.1",
"ms-conf": "^7.0.2",
"ms-files-transport": "^1.0.2",
"ms-perf": "^2.0.0",
"opentracing-js-ioredis": "2.1.2",
"prom-client": "^12.0.0",
"raven": "^2.6.4",
"prom-client": "^13.1.0",
"redis-filtered-sort": "^2.3.0",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"stdout-stream": "^1.4.1",
"uuid": "^8.3.2",
"yargs": "^16.2.0"
"yargs": "^17.0.1"
},
"optionalDependencies": {
"@google-cloud/pubsub": "^2.8.0"
"@google-cloud/pubsub": "^2.10.0"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-strict-mode": "^7.12.1",
"@babel/register": "^7.12.10",
"@makeomatic/deploy": "^10.3.3",
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.15",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/plugin-transform-strict-mode": "^7.12.13",
"@babel/register": "^7.13.14",
"@makeomatic/deploy": "^10.4.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.2.0",
"chai": "^4.3.4",
"codecov": "^3.8.1",
"cross-env": "^7.0.3",
"eslint": "^7.18.0",
"eslint-config-makeomatic": "^5.0.3",
"eslint": "^7.24.0",
"eslint-config-makeomatic": "^5.0.4",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-unicorn": "^27.0.0",
"faker": "^5.2.0",
"json": "^10.0.0",
"mocha": "^8.2.1",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-unicorn": "^33.0.1",
"faker": "^5.5.3",
"json": "^11.0.0",
"mocha": "^9.0.1",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"sinon": "^9.2.4"
"sinon": "^11.1.1"
},
"engines": {
"node": ">= 12.14.0",
Expand Down
1 change: 1 addition & 0 deletions schemas/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@
}
},
"creationInfo": {
"type": "object",
"description": "Contains description of the application that initiated upload and additional upload information.",
"additionalProperties": false,
"properties": {
Expand Down
38 changes: 17 additions & 21 deletions schemas/upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"update": {
"allOf": [
{ "$ref": "common#/definitions/meta" },
{ "minProperties": 1 }
{ "type": "object", "minProperties": 1 }
]
}
}
Expand Down Expand Up @@ -103,20 +103,20 @@
"default": false
}
},
"switch": [{
"allOf": [{
"if": {
"required": ["resumable"],
"properties": { "resumable": { "const": false } }
},
"then": {
"not": {
"required": ["unlisted", "temp"],
"properties": {
"unlisted": { "const": true },
"temp": { "const": true }
}
}
},
"continue": true
}
}, {
"if": {
"required": ["uploadType"],
Expand All @@ -125,22 +125,19 @@
"then": {
"properties": {
"files": {
"contains": {
"allOf": [{
"$ref": "common#/definitions/cp-image"
}, {
"type": "array",
"allOf": [{
"contains": { "$ref": "common#/definitions/cp-image" }
}, {
"contains": {
"type": "object",
"properties": {
"type": {
"const": "c-preview"
}
}
}]
}
"required": ["type"],
"properties": { "type": { "const": "c-preview" } }
}
}]
}
}
},
"continue": true
}
}, {
"if": {
"required": ["uploadType"],
Expand All @@ -154,13 +151,12 @@
}
}
}
},
"continue": true
}
}, {
"if": {
"anyOf": [
{ "properties": { "unlisted": { "const": true } } },
{ "properties": { "temp": { "const": true } } }
{ "required": ["unlisted"], "properties": { "unlisted": { "const": true } } },
{ "required": ["temp"], "properties": { "temp": { "const": true } } }
]
},
"then": { "not": { "required": ["postAction"] } }
Expand Down
2 changes: 1 addition & 1 deletion src/actions/access.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const handlePipeline = require('../utils/pipeline-error');
const fetchData = require('../utils/fetch-data');
Expand Down
2 changes: 1 addition & 1 deletion src/actions/count.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const { HttpStatusError } = require('common-errors');
const { FILES_USER_INDEX_KEY, FILES_USER_INDEX_PUBLIC_KEY } = require('../constant');
Expand Down
2 changes: 1 addition & 1 deletion src/actions/data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');

const { FILES_DATA } = require('../constant');
const fetchData = require('../utils/fetch-data');
Expand Down
2 changes: 1 addition & 1 deletion src/actions/download.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const { HttpStatusError } = require('common-errors');
const { encodeURI } = require('@google-cloud/storage/build/src/util');
Expand Down
8 changes: 4 additions & 4 deletions src/actions/finish.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const assert = require('assert');
const { HttpStatusError } = require('common-errors');
Expand All @@ -24,7 +24,7 @@ const {
FILES_DIRECT_ONLY_FIELD,
FILES_USER_INDEX_KEY,
FILES_USER_INDEX_PUBLIC_KEY,
} = require('../constant.js');
} = require('../constant');

// cached vars
const fields = [
Expand Down Expand Up @@ -139,7 +139,7 @@ async function completeFileUpload({ params }) {
pipeline.persist(postActionKey);
}

await pipeline.exec().then(handlePipeline);
handlePipeline(await pipeline.exec());

if (params.skipProcessing) {
return 'upload completed, processing skipped';
Expand All @@ -150,6 +150,6 @@ async function completeFileUpload({ params }) {
return amqp[action](route, { uploadId });
}

completeFileUpload.transports = [ActionTransport.amqp];
completeFileUpload.transports = [ActionTransport.amqp, ActionTransport.internal];

module.exports = completeFileUpload;
2 changes: 1 addition & 1 deletion src/actions/head.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const { HttpStatusError } = require('common-errors');
const { FILES_USR_ALIAS_PTR } = require('../constant');
const handlePipeline = require('../utils/pipeline-error');
Expand Down
2 changes: 1 addition & 1 deletion src/actions/info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const assert = require('assert');
const { NotImplementedError, HttpStatusError } = require('common-errors');
Expand Down
6 changes: 3 additions & 3 deletions src/actions/list.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const fsort = require('redis-filtered-sort');
const is = require('is');
Expand Down Expand Up @@ -57,7 +57,7 @@ async function interstore(ctx, username) {
}

// ensure we only do 1 operation concurrently
await ctx.dlock.fanout(interstoreKey, async () => {
await ctx.dlock.manager.fanout(interstoreKey, async () => {
const res = await redis.pipeline()
.sinterstore(interstoreKey, filesIndex, tagKeys)
.expire(interstoreKey, ctx.interstoreKeyTTL)
Expand Down Expand Up @@ -268,5 +268,5 @@ async function listFiles({ params }) {
}
}

listFiles.transports = [ActionTransport.amqp];
listFiles.transports = [ActionTransport.amqp, ActionTransport.internal];
module.exports = listFiles;
4 changes: 2 additions & 2 deletions src/actions/process.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const { HttpStatusError } = require('common-errors');
const {
Expand Down Expand Up @@ -100,5 +100,5 @@ async function postProcessFile({ params }) {
return response;
}

postProcessFile.transports = [ActionTransport.amqp];
postProcessFile.transports = [ActionTransport.amqp, ActionTransport.internal];
module.exports = postProcessFile;
2 changes: 1 addition & 1 deletion src/actions/remove.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const hasAccess = require('../utils/has-access');
const fetchData = require('../utils/fetch-data');
Expand Down
2 changes: 1 addition & 1 deletion src/actions/report.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const fsort = require('redis-filtered-sort');
const { NotImplementedError } = require('common-errors');
Expand Down
7 changes: 3 additions & 4 deletions src/actions/sync.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { ActionTransport } = require('@microfleet/core');
const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const fsort = require('redis-filtered-sort');
const moment = require('moment');
const list = require('./list.js');
const acquireLock = require('../utils/acquire-lock');
const list = require('./list');
const { STATUS_PENDING, FILES_INDEX_TEMP } = require('../constant');

// cached filter
Expand Down Expand Up @@ -70,7 +69,7 @@ async function iterateOverUploadedFiles(service, lock, opts = {}) {
*/
module.exports = function sync() {
return Promise
.using(this, acquireLock(this, 'bucket-sync'), iterateOverUploadedFiles);
.using(this, this.dlock.acquireLock(this, 'bucket-sync'), iterateOverUploadedFiles);
};

module.exports.transports = [ActionTransport.amqp];
Loading