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

shell.moveItemToTrash does not work when Recycle Bin is disabled #4974

Closed
50Wliu opened this issue Mar 31, 2016 · 12 comments
Closed

shell.moveItemToTrash does not work when Recycle Bin is disabled #4974

50Wliu opened this issue Mar 31, 2016 · 12 comments

Comments

@50Wliu
Copy link
Contributor

50Wliu commented Mar 31, 2016

  • Electron version: 0.36.8
  • Operating system: Windows 10 x64

I have the Recycle Bin set up to immediately delete files. This seems to cause shell.moveItemToTrash() to fail. As this is a native Windows option (at least for Windows 7+), it should be supported.

recycle-bin-immediately-delete

@kevinsawicki
Copy link
Contributor

/cc @felixrieseberg

@felixrieseberg
Copy link
Member

Did a quick investigation: This won't be easy.

@allistercsmith
Copy link

allistercsmith commented Jun 13, 2016

Hey guys,

Any progress on this issue yet? Just wanted to add that this is an issue for OS X too. I have almost no experience with objective-C coding, so unfortunately can't be much help coding/testing wise.

However, just browsing around the web a bit (here, just search for NSFileManager Trash APIs), I noticed that there is a NSFeatureUnsupportedError returned if trash isn't supported for the volume.

Perhaps we can make a change in the platform_util_mac.mm file to the following lines:

bool MoveItemToTrash(const base::FilePath& full_path) {
  NSString* path_string = base::SysUTF8ToNSString(full_path.value());
  BOOL status = [[NSFileManager defaultManager]
                trashItemAtURL:[NSURL fileURLWithPath:path_string]
                resultingItemURL:nil
                error:nil];

  // Check if error = NSFeatureUnsupportedError.
  // If so, make a call to removeItemAtPath instead to directly delete the file.
  // Otherwise, continue as normal.

  if (!path_string || !status)
    LOG(WARNING) << "NSWorkspace failed to move file " << full_path.value()
                 << " to trash";
  return status;
}

There may be a bit more work involved with error messages/logging, but is there anyone who could try this out?

@slikts
Copy link

slikts commented Jul 7, 2016

This is a rather crippling issue, but thankfully a workaround exists for Windows (see atom/tree-view#856 (comment)).

@codebytere
Copy link
Member

closing due to abandonment.

@50Wliu
Copy link
Contributor Author

50Wliu commented Sep 27, 2017

@codebytere would you mind reopening this? I originally opened it on behalf of Atom (atom/tree-view#856), and it appears that this is still a bug on at least Electron 1.6.9.

@electron electron deleted a comment from jcj52436999 Sep 27, 2017
@electron electron deleted a comment from jcj52436999 Sep 27, 2017
@MarshallOfSound
Copy link
Member

Deleted auto-reply emails

@codebytere
Copy link
Member

@50Wliu for sure! we're just making an effort to weed out abandoned issues :)

@codebytere
Copy link
Member

We are no longer implementing bugfixes for versions of Electron <= 1.7.x, so i'm going to close this issue but if it is still persisting in more recent versions of Electron we can certainly reopen it!

@50Wliu
Copy link
Contributor Author

50Wliu commented Sep 24, 2018

@codebytere I can confirm that this is still an issue using Electron 2.0.9. To test, I set the Recycle Bin to delete all items automatically, then opened Atom and attempted to delete a file using the Tree View. The operation failed.

@sofianguy
Copy link
Contributor

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases.

If you're still experiencing this issue in Electron v4.2.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@sofianguy sofianguy added the blocked/need-info ❌ Cannot proceed without more information label Aug 9, 2019
@codebytere codebytere added 7-0-x enhancement ✨ and removed blocked/need-info ❌ Cannot proceed without more information 2-0-x bug 🪲 labels Aug 9, 2019
@codebytere
Copy link
Member

Closing as we've implemented this on macOS with #19700 and Windows is not possible at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants