1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00
Peertube/server/core/helpers/fs.ts
2023-10-05 11:09:11 +02:00

12 lines
311 B
TypeScript

import { move } from 'fs-extra/esm'
import { rename } from 'fs/promises'
export async function tryAtomicMove (src: string, destination: string) {
try {
await rename(src, destination)
} catch (err) {
if (err?.code !== 'EXDEV') throw err
return move(src, destination, { overwrite: true })
}
}