coderaiser/cloudcmd

Moving files in the same partition path will result in a copy file operation

LarkinZero opened this issue · 9 comments

When moving files under the same partition path, I observed that there is no direct move, which produces a copy-like operation, not as fast as executing the execute mv command.
This can be very annoying when moving large files.
This problem occurs when files are moved from the /volume2/Files path to /volume2/Files1
image

  • Version (cloudcmd -v):16.6.0
  • Node Version node -v:15.13.0
  • OS (uname -a on Linux):Synology DSM Docker
  • Browser name/version: Chrome
  • Used Command Line Parameters:
  • Changed Config:

It first tries to rename files and if error happened move files. Could you provide more details, or add some console.log to determine what kind of an error you have?

I added some consoles in the moveFiles function and the removeAll function.
It took 6 seconds to move a 776MB file to another folder under the same partition.

test code

const moveFiles = require('@cloudcmd/move-files');
const wraptile = require('wraptile');

const move = moveFiles("/volume2/File/","/volume2/File1/",["proxmox-ve_6.1-1.iso"])
move.on('file', console.log)
    .on('error', console.log)
    .on('end', wraptile(console.log, 'done'));
console.log(new Date());

image

/volume2/File is a shared directory for the Synology DSM.
/volume2/File1 is created by sudo mkdir /volume2/File1.
/volume2/File2 is created by sudo mkdir /volume2/File2.
This problem occurs when files in the directory /volume2/File are moved to /volume2/File1.
After I move the files in /volume2/File1 to /volume2/File2, the logs I added in moveFiles function are not generated.
image

Let’s try to use @cloudcmd/rename-files directly, and take a look what error it produce.

Let’s try to use @cloudcmd/rename-files directly, and take a look what error it produce.

EXDEV: cross-device link not permitted, rename '/volume2/File/proxmox-ve_6.1-1.iso' -> '/volume2/File1/proxmox-ve_6.1-1.iso'

test code

const renameFiles = require('@cloudcmd/rename-files');

const ok = () => 'ok';
const error = (e) => e.message;

renameFiles('/volume2/File/', '/volume2/File1/', ['proxmox-ve_6.1-1.iso'])
    .then(ok)
    .catch(error)
    .then(console.log);

This looks like a problem with fs.rename

> fs.rename('/volume2/File/proxmox-ve_6.1-1.iso','/volume2/File1/proxmox-ve_6.1-1.iso',(err) => { if (err) throw err;  console.log('Rename complete!');})
undefined
> Uncaught:
[Error: EXDEV: cross-device link not permitted, rename '/volume2/File/proxmox-ve_6.1-1.iso' -> '/volume2/File1/proxmox-ve_6.1-1.iso'] {
  errno: -18,
  code: 'EXDEV',
  syscall: 'rename',
  path: '/volume2/File/proxmox-ve_6.1-1.iso',
  dest: '/volume2/File1/proxmox-ve_6.1-1.iso'
}

Yes, you better create an issue in nodejs repo.
Looks like this file is a symlink or something…

Looks like it’s related to Synology, and this is the place that should be fixed 🤷

This is how Synology Technical Support responded to me.

Sorry, low-level commands are not supported by Synology nas, and we do not recommend you to do such operations on the low level, if you just want to move files, it is recommended to do it in the file station's ui, or you can use the shell's cp command if you must do it on the low level.
It is important to note that modifications to the base layer are a very dangerous operation, and if the modifications are too large, we will not be able to provide effective technical support and will only be able to reinstall the dsm system to restore normal use.