mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-08 15:22:35 +00:00
Merge pull request #5968 from overleaf/em-oversized-docs
Get path from Mongo when fixing oversized docs GitOrigin-RevId: 07d5425d37faf935c162f57f63f6f1cf4c62d592
This commit is contained in:
parent
8207197e33
commit
993a6d0eb9
1 changed files with 9 additions and 4 deletions
|
@ -5,6 +5,7 @@ const DocstoreManager = require('../app/src/Features/Docstore/DocstoreManager')
|
|||
const FileStoreHandler = require('../app/src/Features/FileStore/FileStoreHandler')
|
||||
const FileWriter = require('../app/src/infrastructure/FileWriter')
|
||||
const ProjectEntityMongoUpdateHandler = require('../app/src/Features/Project/ProjectEntityMongoUpdateHandler')
|
||||
const ProjectLocator = require('../app/src/Features/Project/ProjectLocator')
|
||||
const RedisWrapper = require('@overleaf/redis-wrapper')
|
||||
const Settings = require('@overleaf/settings')
|
||||
|
||||
|
@ -55,7 +56,7 @@ async function processProject(projectId) {
|
|||
}
|
||||
|
||||
async function processDoc(projectId, docId) {
|
||||
const doc = await getDocFromRedis(docId)
|
||||
const doc = await getDoc(projectId, docId)
|
||||
const size = doc.lines.reduce((sum, line) => sum + line.length + 1, 0)
|
||||
if (size > opts.maxDocSize) {
|
||||
if (
|
||||
|
@ -89,15 +90,19 @@ async function getDocIds(projectId) {
|
|||
return docIds
|
||||
}
|
||||
|
||||
async function getDocFromRedis(docId) {
|
||||
async function getDoc(projectId, docId) {
|
||||
const lines = await redis.get(`doclines:{${docId}}`)
|
||||
const path = await redis.get(`Pathname:{${docId}}`)
|
||||
const ranges = await redis.get(`Ranges:{${docId}}`)
|
||||
const { path } = await ProjectLocator.promises.findElement({
|
||||
project_id: projectId,
|
||||
element_id: docId,
|
||||
type: 'doc',
|
||||
})
|
||||
return {
|
||||
id: docId,
|
||||
lines: JSON.parse(lines),
|
||||
ranges: ranges ? JSON.parse(ranges) : {},
|
||||
path,
|
||||
path: path.fileSystem,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue