2019-12-16 05:24:37 -05:00
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
2019-12-16 05:24:35 -05:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS103: Rewrite code to no longer use __guard__
|
|
|
|
* DS205: Consider reworking code to avoid use of IIFEs
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2019-12-16 05:42:31 -05:00
|
|
|
const settings = require('settings-sharelatex')
|
|
|
|
const logger = require('logger-sharelatex')
|
2014-02-25 04:10:22 -05:00
|
|
|
|
2019-12-16 05:24:35 -05:00
|
|
|
// assume s3 if none specified
|
2019-12-16 05:42:31 -05:00
|
|
|
__guard__(
|
|
|
|
settings != null ? settings.filestore : undefined,
|
|
|
|
x => x.backend || (settings.filestore.backend = 's3')
|
|
|
|
)
|
2014-02-26 06:58:48 -05:00
|
|
|
|
2019-12-16 05:42:31 -05:00
|
|
|
logger.log(
|
|
|
|
{
|
|
|
|
backend: __guard__(
|
|
|
|
settings != null ? settings.filestore : undefined,
|
|
|
|
x1 => x1.backend
|
|
|
|
)
|
|
|
|
},
|
|
|
|
'Loading backend'
|
|
|
|
)
|
|
|
|
module.exports = (() => {
|
|
|
|
switch (
|
|
|
|
__guard__(
|
|
|
|
settings != null ? settings.filestore : undefined,
|
|
|
|
x2 => x2.backend
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
case 'aws-sdk':
|
|
|
|
return require('./AWSSDKPersistorManager')
|
|
|
|
case 's3':
|
|
|
|
return require('./S3PersistorManager')
|
|
|
|
case 'fs':
|
|
|
|
return require('./FSPersistorManager')
|
|
|
|
default:
|
|
|
|
throw new Error(
|
|
|
|
`Unknown filestore backend: ${settings.filestore.backend}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})()
|
2019-12-16 05:24:35 -05:00
|
|
|
|
|
|
|
function __guard__(value, transform) {
|
2019-12-16 05:42:31 -05:00
|
|
|
return typeof value !== 'undefined' && value !== null
|
|
|
|
? transform(value)
|
|
|
|
: undefined
|
|
|
|
}
|