fiftyone.pipeline.engines
Advanced tools
Comparing version 4.4.2 to 4.4.3
@@ -29,3 +29,6 @@ /* ********************************************************************* | ||
const url = require('url'); | ||
const EventEmitter = require('events'); | ||
const AutoUpdateStatus = require('./autoUpdateStatus'); | ||
const minToMs = (min) => min * 60000; | ||
@@ -51,5 +54,18 @@ | ||
constructor (pipeline) { | ||
this.registerPipeline(pipeline); | ||
this.eventEmitter = new EventEmitter(); | ||
} | ||
registerPipeline(pipeline) { | ||
this.pipeline = pipeline; | ||
} | ||
on (listener, callback) { | ||
this.eventEmitter.on(listener, callback); | ||
} | ||
once(listener, callback) { | ||
this.eventEmitter.once(listener, callback); | ||
} | ||
/** | ||
@@ -104,4 +120,7 @@ * Method that updates a datafile when it is due an update | ||
"' for engine '" + | ||
dataFile.flowElement.dataKey + "'" | ||
); | ||
dataFile.flowElement.dataKey + "'"); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_ERR_429_TOO_MANY_ATTEMPTS, | ||
dataFile); | ||
break; | ||
@@ -115,2 +134,6 @@ case (304): | ||
dataFile.flowElement.dataKey + "'"); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_NOT_NEEDED, | ||
dataFile); | ||
break; | ||
@@ -122,4 +145,7 @@ case (403): | ||
"' for engine '" + | ||
dataFile.flowElement.dataKey + "'" | ||
); | ||
dataFile.flowElement.dataKey + "'"); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_ERR_403_FORBIDDEN, | ||
dataFile); | ||
break; | ||
@@ -133,4 +159,7 @@ default: | ||
"' for engine '" + | ||
dataFile.flowElement.dataKey + "'" | ||
); | ||
dataFile.flowElement.dataKey + "'"); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_HTTPS_ERR, | ||
dataFile); | ||
break; | ||
@@ -145,3 +174,3 @@ } | ||
const filename = dataFile.tempDataDirectory + | ||
'/' + dataFile.identifier + | ||
'/' + dataFile.identifier + | ||
Date.now(); | ||
@@ -175,2 +204,6 @@ | ||
dataFileUpdateService.checkNextUpdate(dataFile); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_ERR_MD5_VALIDATION_FAILED, | ||
dataFile); | ||
} else { | ||
@@ -203,2 +236,6 @@ dataFileUpdateService.processFile(dataFile, filename); | ||
dataFileUpdateService.pipeline.log('error', err); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_MASTER_FILE_CANT_RENAME, | ||
dataFile); | ||
} | ||
@@ -208,9 +245,19 @@ | ||
if (err) { | ||
dataFileUpdateService.pipe.log('error', err); | ||
dataFileUpdateService.pipeline.log('error', err); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_NEW_FILE_CANT_RENAME, | ||
dataFile); | ||
} | ||
dataFile.refresh(); | ||
try { | ||
dataFile.refresh(); | ||
} catch (e) { | ||
dataFileUpdateService.pipeline.log('error', e); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_REFRESH_FAILED, | ||
dataFile); | ||
} | ||
dataFileUpdateService.checkNextUpdate(dataFile); | ||
dataFile.updating = false; | ||
@@ -222,3 +269,11 @@ | ||
dataFileUpdateService.pipeline.log('error', err); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_NEW_FILE_CANT_RENAME, | ||
dataFile); | ||
} | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_SUCCESS, | ||
dataFile); | ||
}); | ||
@@ -243,2 +298,6 @@ }); | ||
dataFileUpdateService.pipeline.log('error', err); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_ERR_READING_STREAM, | ||
dataFile); | ||
} | ||
@@ -249,2 +308,6 @@ | ||
dataFileUpdateService.pipeline.log('error', err); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_ERR_READING_STREAM, | ||
dataFile); | ||
} | ||
@@ -317,2 +380,3 @@ | ||
if (dataFile.fileSystemWatcher) { | ||
const dataFileUpdateService = this; | ||
const watch = function () { | ||
@@ -322,2 +386,6 @@ fs.watch(dataFile.path, { persistent: false }, function (event) { | ||
dataFile.refresh(); | ||
dataFileUpdateService.eventEmitter.emit( | ||
'updateComplete', | ||
AutoUpdateStatus.AUTO_UPDATE_SUCCESS, | ||
dataFile); | ||
} | ||
@@ -324,0 +392,0 @@ }); |
@@ -33,4 +33,6 @@ /* ********************************************************************* | ||
MissingPropertyService: require('./missingPropertyService'), | ||
DataFileUpdateService: require('./dataFileUpdateService'), | ||
AutoUpdateStatus: require('./autoUpdateStatus'), | ||
Tracker: require('./tracker') | ||
}; |
{ | ||
"name": "fiftyone.pipeline.engines", | ||
"version": "4.4.2", | ||
"version": "4.4.3", | ||
"description": "Shared base functionality for implementing engines for the 51Degrees Pipeline API", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"fiftyone.pipeline.core": "^4.4.2" | ||
"fiftyone.pipeline.core": "^4.4.3" | ||
}, | ||
@@ -17,0 +17,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84827
34
2232