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

FileService's copy/move should not modify the target URI when destination exist #9151

Open
kittaakos opened this issue Mar 4, 2021 · 0 comments
Labels
filesystem issues related to the filesystem

Comments

@kittaakos
Copy link
Contributor

Bug Description:

From here:

The FileService API should not change the target URI when moving/copying. Imagine you have a Node.js call:

fs.copyFile('/path/to/my/file', '/path/to/desired/destination', cb)

And eventually, it will copy my file to /path/to/desired/destination_copy just because /path/to/desired/destination already exists. No, the FileService should fail and not modify the destination.

Related: #9037

The current code modifies the target URI if !overwrite . !overwrite has the same meaning as COPYFILE_EXCL from Node. Node fails with EEXIST. I would expect a failure too. Thoughts?

if (exists && !overwrite) {
const parent = await this.resolve(target.parent);
const name = target.path.name + '_copy';
target = FileSystemUtils.generateUniqueResourceURI(target.parent, parent, name, target.path.ext);
}

Steps to Reproduce:

Additional Information

  • Operating System:
  • Theia Version:
@kittaakos kittaakos self-assigned this Mar 4, 2021
@vince-fugnitto vince-fugnitto added the filesystem issues related to the filesystem label Mar 4, 2021
@kittaakos kittaakos removed their assignment Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem issues related to the filesystem
Projects
None yet
Development

No branches or pull requests

2 participants