Remove unnecessary symlink check

GitOrigin-RevId: 08d7295403a258818276b9fbd7666a20fbc2e00f
This commit is contained in:
andrew rumble
2024-09-24 08:05:06 +00:00
committed by Copybot
parent 3fa35ef03a
commit c387e60a28
2 changed files with 43 additions and 69 deletions
@@ -2,7 +2,7 @@ const archiver = require('archiver')
const OutputCacheManager = require('./OutputCacheManager')
const OutputFileFinder = require('./OutputFileFinder')
const Settings = require('@overleaf/settings')
const { open, realpath } = require('node:fs/promises')
const { open } = require('node:fs/promises')
const path = require('path')
const { NotFoundError } = require('./Errors')
@@ -20,23 +20,6 @@ function getContentDir(projectId, userId) {
return `${Settings.path.outputDir}/${subDir}/`
}
/**
* Is the provided path a symlink?
* @param {string} path
* @return {Promise<boolean>}
*/
async function isSymlink(path) {
try {
const realPath = await realpath(path)
return realPath !== path
} catch (error) {
if (error.code === 'ELOOP') {
return true
}
throw error
}
}
module.exports = {
async archiveFilesForBuild(projectId, userId, build) {
const validFiles = await this._getAllOutputFiles(projectId, userId, build)
@@ -47,11 +30,9 @@ module.exports = {
for (const file of validFiles) {
try {
if (!(await isSymlink(file))) {
const fileHandle = await open(file, 'r')
const fileStream = fileHandle.createReadStream()
archive.append(fileStream, { name: path.basename(file) })
}
const fileHandle = await open(file, 'r')
const fileStream = fileHandle.createReadStream()
archive.append(fileStream, { name: path.basename(file) })
} catch (error) {
missingFiles.push(file)
}