ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

13 lines
311 B

  1. import { move } from 'fs-extra/esm'
  2. import { rename } from 'fs/promises'
  3. export async function tryAtomicMove (src: string, destination: string) {
  4. try {
  5. await rename(src, destination)
  6. } catch (err) {
  7. if (err?.code !== 'EXDEV') throw err
  8. return move(src, destination, { overwrite: true })
  9. }
  10. }