fix(immutable-backups): index files aren't immutable anymore

This commit is contained in:
Florent Beauchamp 2024-02-01 15:21:02 +00:00 committed by Julien Fontanet
parent 619b3f3c78
commit 70f2e50274

View File

@ -27,17 +27,6 @@ export async function indexFile(path, immutabilityIndexPath) {
if (err.code === 'ENOENT') {
await fs.mkdir(dirname(indexFilePath), { recursive: true })
await fs.writeFile(indexFilePath, path)
} else if (err.code === 'EPERM') {
// an immutable file alreay exist : not a problem if it contains the right target
const { size } = await fs.stat(indexFilePath)
if (size.length > 1024 * 1024) {
throw new Error(`Index file at ${indexFilePath} is too big, ${size} bytes `)
}
const existingContent = await fs.readFile(indexFilePath, { encoding: 'utf8' })
if (existingContent !== path) {
throw new Error(`Index file at ${indexFilePath}, should contains ${path}, but contains ${existingContent}`)
}
throw err
} else {
throw err
}