Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufs.copyFileSync fails when src and destination folders exist in separate volumes #429

Open
iamogbz opened this issue Mar 18, 2020 · 1 comment

Comments

@iamogbz
Copy link

iamogbz commented Mar 18, 2020

Description

Copying a file from an existing location in one fs module into an existing location in another fs module fails

Steps to reproduce

With file

const fs = require('fs')
const path = require('path')

const { vol } = require('memfs')
const { ufs } = require('unionfs')

ufs.use(vol).use(fs)

const file1 = 'testfile.txt'
const file2 = 'somefolder/testfile.txt'

try {
    vol.mkdirSync(path.dirname(file2), { recursive: true })
    fs.writeFileSync(file1, '')
    ufs.copyFileSync(file1, file2)
} finally {
    if (fs.existsSync(file1)) fs.unlinkSync(file1)
}

Results

./node_modules/unionfs/lib/union.js:636
                    throw err;
                    ^

Error: ENOENT: no such file or directory, open 'testfile.txt'
    at createError (./node_modules/memfs/lib/volume.js:130:17)
    at Volume.openFile (./node_modules/memfs/lib/volume.js:818:15)
    at Volume.openBase (./node_modules/memfs/lib/volume.js:822:25)
    at Volume.openSync (./node_modules/memfs/lib/volume.js:833:21)
    at Volume.readFileBase (./node_modules/memfs/lib/volume.js:919:23)
    at Volume.readFileSync (./node_modules/memfs/lib/volume.js:934:21)
    at Volume.copyFileBase (./node_modules/memfs/lib/volume.js:1113:24)
    at Volume.copyFileSync (./node_modules/memfs/lib/volume.js:1127:21)
    at Union.syncMethod (./node_modules/unionfs/lib/union.js:630:35)
    at Union.this_1.<computed> [as copyFileSync] (./node_modules/unionfs/lib/union.js:525:34) {
  code: 'ENOENT',
  prev: Error: ENOENT: no such file or directory, copyfile 'testfile.txt' -> 'somefolder/testfile.txt'
      at Object.copyFileSync (fs.js:1801:3)
      at Union.syncMethod (./node_modules/unionfs/lib/union.js:630:35)
      at Union.this_1.<computed> [as copyFileSync] (./node_modules/unionfs/lib/union.js:525:34)
      at Object.<anonymous> (./example.js:16:9)
      at Module._compile (internal/modules/cjs/loader.js:936:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
      at Module.load (internal/modules/cjs/loader.js:790:32)
      at Function.Module._load (internal/modules/cjs/loader.js:703:12)
      at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
      at internal/main/run_main_module.js:17:11 {
    errno: -2,
    syscall: 'copyfile',
    code: 'ENOENT',
    path: 'testfile.txt',
    dest: 'somefolder/testfile.txt',
    prev: null
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants