mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
4e507197fc
This reverts commit 0cce792604c258538cf012486e7329fa1be7da0f, reversing changes made to 08b606e22f855121b2d8a2832a5d7e2f45836c3f.
37 lines
951 B
JavaScript
37 lines
951 B
JavaScript
const settings = require('settings-sharelatex')
|
|
const logger = require('logger-sharelatex')
|
|
|
|
logger.log(
|
|
{
|
|
backend: settings.filestore.backend,
|
|
fallback: settings.filestore.fallback && settings.filestore.fallback.backend
|
|
},
|
|
'Loading backend'
|
|
)
|
|
if (!settings.filestore.backend) {
|
|
throw new Error('no backend specified - config incomplete')
|
|
}
|
|
|
|
function getPersistor(backend) {
|
|
switch (backend) {
|
|
case 'aws-sdk':
|
|
case 's3':
|
|
return require('./S3Persistor')
|
|
case 'fs':
|
|
return require('./FSPersistor')
|
|
default:
|
|
throw new Error(`unknown filestore backend: ${backend}`)
|
|
}
|
|
}
|
|
|
|
let persistor = getPersistor(settings.filestore.backend)
|
|
|
|
if (settings.filestore.fallback && settings.filestore.fallback.backend) {
|
|
const migrationPersistor = require('./MigrationPersistor')
|
|
persistor = migrationPersistor(
|
|
persistor,
|
|
getPersistor(settings.filestore.fallback.backend)
|
|
)
|
|
}
|
|
|
|
module.exports = persistor
|