mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #18756 from overleaf/csh-issue-18573-remove-filestore-public-code
Remove public files code from filestore GitOrigin-RevId: 05aedc8bc1068dc6cfb17c9f9402fddce273b4a9
This commit is contained in:
parent
0f2aaa6c0c
commit
fa8161d4ce
9 changed files with 16 additions and 76 deletions
|
@ -50,6 +50,12 @@ lint:
|
|||
lint_fix:
|
||||
$(RUN_LINTING) lint:fix
|
||||
|
||||
lint_styles:
|
||||
$(RUN_LINTING) lint:styles
|
||||
|
||||
lint_styles_fix:
|
||||
$(RUN_LINTING) lint:styles:fix
|
||||
|
||||
typecheck:
|
||||
$(RUN_LINTING) types:check
|
||||
|
||||
|
|
|
@ -86,6 +86,12 @@ app.delete(
|
|||
fileController.deleteProject
|
||||
)
|
||||
|
||||
app.get(
|
||||
'/project/:project_id/size',
|
||||
keyBuilder.userProjectKeyMiddleware,
|
||||
fileController.directorySize
|
||||
)
|
||||
|
||||
app.head(
|
||||
'/template/:template_id/v/:version/:format',
|
||||
keyBuilder.templateFileKeyMiddleware,
|
||||
|
@ -107,39 +113,6 @@ app.post(
|
|||
fileController.insertFile
|
||||
)
|
||||
|
||||
app.head(
|
||||
'/project/:project_id/public/:public_file_id',
|
||||
keyBuilder.publicFileKeyMiddleware,
|
||||
fileController.getFileHead
|
||||
)
|
||||
app.get(
|
||||
'/project/:project_id/public/:public_file_id',
|
||||
keyBuilder.publicFileKeyMiddleware,
|
||||
fileController.getFile
|
||||
)
|
||||
app.post(
|
||||
'/project/:project_id/public/:public_file_id',
|
||||
keyBuilder.publicFileKeyMiddleware,
|
||||
fileController.insertFile
|
||||
)
|
||||
app.put(
|
||||
'/project/:project_id/public/:public_file_id',
|
||||
keyBuilder.publicFileKeyMiddleware,
|
||||
bodyParser.json(),
|
||||
fileController.copyFile
|
||||
)
|
||||
app.delete(
|
||||
'/project/:project_id/public/:public_file_id',
|
||||
keyBuilder.publicFileKeyMiddleware,
|
||||
fileController.deleteFile
|
||||
)
|
||||
|
||||
app.get(
|
||||
'/project/:project_id/size',
|
||||
keyBuilder.publicProjectKeyMiddleware,
|
||||
fileController.directorySize
|
||||
)
|
||||
|
||||
app.get(
|
||||
'/bucket/:bucket/key/*',
|
||||
keyBuilder.bucketFileKeyMiddleware,
|
||||
|
|
|
@ -5,8 +5,6 @@ module.exports = {
|
|||
addCachingToKey,
|
||||
userFileKeyMiddleware,
|
||||
userProjectKeyMiddleware,
|
||||
publicFileKeyMiddleware,
|
||||
publicProjectKeyMiddleware,
|
||||
bucketFileKeyMiddleware,
|
||||
templateFileKeyMiddleware,
|
||||
}
|
||||
|
@ -40,23 +38,12 @@ function userFileKeyMiddleware(req, res, next) {
|
|||
|
||||
function userProjectKeyMiddleware(req, res, next) {
|
||||
const { project_id: projectId } = req.params
|
||||
req.project_id = projectId
|
||||
req.key = `${projectId}/`
|
||||
req.bucket = settings.filestore.stores.user_files
|
||||
next()
|
||||
}
|
||||
|
||||
function publicFileKeyMiddleware(req, res, next) {
|
||||
if (settings.filestore.stores.public_files == null) {
|
||||
return res.status(501).send('public files not available')
|
||||
}
|
||||
|
||||
const { project_id: projectId, public_file_id: publicFileId } = req.params
|
||||
req.key = `${projectId}/${publicFileId}`
|
||||
req.bucket = settings.filestore.stores.public_files
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
function bucketFileKeyMiddleware(req, res, next) {
|
||||
req.bucket = req.params.bucket
|
||||
req.key = req.params[0]
|
||||
|
@ -82,12 +69,3 @@ function templateFileKeyMiddleware(req, res, next) {
|
|||
|
||||
next()
|
||||
}
|
||||
|
||||
function publicProjectKeyMiddleware(req, res, next) {
|
||||
const { project_id: projectId } = req.params
|
||||
|
||||
req.project_id = projectId
|
||||
req.bucket = settings.filestore.stores.user_files
|
||||
|
||||
next()
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ filestore
|
|||
--data-dirs=uploads,user_files,template_files
|
||||
--dependencies=s3,gcs
|
||||
--docker-repos=gcr.io/overleaf-ops,us-east1-docker.pkg.dev/overleaf-ops/ol-docker
|
||||
--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,AWS_S3_PUBLIC_FILES_BUCKET_NAME=fake_public_files,GCS_USER_FILES_BUCKET_NAME=fake_userfiles,GCS_TEMPLATE_FILES_BUCKET_NAME=fake_templatefiles,GCS_PUBLIC_FILES_BUCKET_NAME=fake_publicfiles
|
||||
--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,GCS_USER_FILES_BUCKET_NAME=fake_userfiles,GCS_TEMPLATE_FILES_BUCKET_NAME=fake_templatefiles
|
||||
--env-pass-through=
|
||||
--esmock-loader=False
|
||||
--node-version=18.20.2
|
||||
|
|
|
@ -17,8 +17,6 @@ if (process.env.BACKEND == null) {
|
|||
process.env.AWS_S3_USER_FILES_BUCKET_NAME
|
||||
process.env.TEMPLATE_FILES_BUCKET_NAME =
|
||||
process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME
|
||||
process.env.PUBLIC_FILES_BUCKET_NAME =
|
||||
process.env.AWS_S3_PUBLIC_FILES_BUCKET_NAME
|
||||
} else {
|
||||
process.env.BACKEND = 'fs'
|
||||
process.env.USER_FILES_BUCKET_NAME = Path.join(__dirname, '../user_files')
|
||||
|
@ -26,10 +24,6 @@ if (process.env.BACKEND == null) {
|
|||
__dirname,
|
||||
'../template_files'
|
||||
)
|
||||
process.env.PUBLIC_FILES_BUCKET_NAME = Path.join(
|
||||
__dirname,
|
||||
'../public_files'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +73,6 @@ const settings = {
|
|||
stores: {
|
||||
user_files: process.env.USER_FILES_BUCKET_NAME,
|
||||
template_files: process.env.TEMPLATE_FILES_BUCKET_NAME,
|
||||
public_files: process.env.PUBLIC_FILES_BUCKET_NAME,
|
||||
},
|
||||
|
||||
fallback: process.env.FALLBACK_BACKEND
|
||||
|
|
|
@ -35,10 +35,8 @@ services:
|
|||
USE_PROM_METRICS: "true"
|
||||
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
|
||||
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
|
||||
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
|
||||
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
|
||||
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
|
||||
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
|
@ -58,7 +56,7 @@ services:
|
|||
s3:
|
||||
image: adobe/s3mock:2.4.14
|
||||
environment:
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
|
||||
- initialBuckets=fake_user_files,fake_template_files,bucket
|
||||
healthcheck:
|
||||
test: wget --quiet --output-document=/dev/null http://localhost:9090
|
||||
interval: 1s
|
||||
|
|
|
@ -51,10 +51,8 @@ services:
|
|||
USE_PROM_METRICS: "true"
|
||||
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
|
||||
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
|
||||
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
|
||||
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
|
||||
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
|
||||
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
|
||||
user: node
|
||||
depends_on:
|
||||
s3:
|
||||
|
@ -66,7 +64,7 @@ services:
|
|||
s3:
|
||||
image: adobe/s3mock:2.4.14
|
||||
environment:
|
||||
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
|
||||
- initialBuckets=fake_user_files,fake_template_files,bucket
|
||||
healthcheck:
|
||||
test: wget --quiet --output-document=/dev/null http://localhost:9090
|
||||
interval: 1s
|
||||
|
|
|
@ -88,10 +88,8 @@ describe('Filestore', function () {
|
|||
|
||||
const BUCKET_NAMES = [
|
||||
process.env.GCS_USER_FILES_BUCKET_NAME,
|
||||
process.env.GCS_PUBLIC_FILES_BUCKET_NAME,
|
||||
process.env.GCS_TEMPLATE_FILES_BUCKET_NAME,
|
||||
`${process.env.GCS_USER_FILES_BUCKET_NAME}-deleted`,
|
||||
`${process.env.GCS_PUBLIC_FILES_BUCKET_NAME}-deleted`,
|
||||
`${process.env.GCS_TEMPLATE_FILES_BUCKET_NAME}-deleted`,
|
||||
]
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ function s3Stores() {
|
|||
return {
|
||||
user_files: process.env.AWS_S3_USER_FILES_BUCKET_NAME,
|
||||
template_files: process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME,
|
||||
public_files: process.env.AWS_S3_PUBLIC_FILES_BUCKET_NAME,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,14 +43,12 @@ function gcsStores() {
|
|||
return {
|
||||
user_files: process.env.GCS_USER_FILES_BUCKET_NAME,
|
||||
template_files: process.env.GCS_TEMPLATE_FILES_BUCKET_NAME,
|
||||
public_files: process.env.GCS_PUBLIC_FILES_BUCKET_NAME,
|
||||
}
|
||||
}
|
||||
|
||||
function fsStores() {
|
||||
return {
|
||||
user_files: Path.resolve(__dirname, '../../../user_files'),
|
||||
public_files: Path.resolve(__dirname, '../../../public_files'),
|
||||
template_files: Path.resolve(__dirname, '../../../template_files'),
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +56,6 @@ function fsStores() {
|
|||
function fallbackStores(primaryConfig, fallbackConfig) {
|
||||
return {
|
||||
[primaryConfig.user_files]: fallbackConfig.user_files,
|
||||
[primaryConfig.public_files]: fallbackConfig.public_files,
|
||||
[primaryConfig.template_files]: fallbackConfig.template_files,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue