Skip to content

Move operation error "EXDEV: cross-device link not permitted, rename" #515

@stanleyxu2005

Description

@stanleyxu2005

I ran into problem with moving a folder for a physical drive to another (mounted) drive.
My application is running at D:\.
fsn.move('source\dir', 'T:\target\dir')

Error: EXDEV: cross-device link not permitted, rename 'D:\source\dir' -> 'T:\target\dir' 
{
  errno: -4037,
  code: 'EXDEV',
  syscall: 'rename',
  path: 'D:\source\dir',
  dest: 'T:\target\dir'
}

The workaround is
fsn.move(path.resolve('source\dir'), 'T:\target\dir')
Here is my pull request

I checked the implementation of fsn.move, it seems source and destination are resolved on the fly, but not everywhere. Is there a particular reason for that?

export async function move(source: string, destination: string, options: MoveOptions = {}): Promise<void> {
const overwrite = options.overwrite || false;
if (resolve(source) === resolve(destination)) return fsp.access(source);
const myStat = await fsp.lstat(source);
if (myStat.isDirectory() && isSrcKid(source, destination)) {
throw new Error('FS-NEXTRA: Moving a parent directory into a child will result in an infinite loop.');
}
await mkdirs(dirname(destination));
if (overwrite) {
await remove(destination);
} else if (await pathExists(destination)) {
throw new Error('FS-NEXTRA: Destination already exists.');
}
try {
return await fsp.rename(source, destination);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions