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

Migrate deprecated NSWorkspaceRecycleOperation #2113

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 19 additions & 21 deletions macosx/Torrent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -574,30 +574,28 @@ - (void)setPriority:(tr_priority_t)priority

+ (BOOL)trashFile:(NSString*)path error:(NSError**)error
{
//attempt to move to trash
if (![NSWorkspace.sharedWorkspace performFileOperation:NSWorkspaceRecycleOperation source:path.stringByDeletingLastPathComponent
destination:@""
files:@[ path.lastPathComponent ]
tag:nil])
// Attempt to move to trash
if ([NSFileManager.defaultManager trashItemAtURL:[NSURL fileURLWithPath:path] resultingItemURL:nil error:nil])
{
//if cannot trash, just delete it (will work if it's on a remote volume)
NSError* localError;
if (![NSFileManager.defaultManager removeItemAtPath:path error:&localError])
{
NSLog(@"old Could not trash %@: %@", path, localError.localizedDescription);
if (error != nil)
{
*error = localError;
}
return NO;
}
else
{
NSLog(@"old removed %@", path);
}
NSLog(@"Old moved to Trash %@", path);
return YES;
}

return YES;
// If cannot trash, just delete it (will work if it's on a remote volume)
NSError* localError;
if ([NSFileManager.defaultManager removeItemAtPath:path error:&localError])
{
NSLog(@"Old removed %@", path);
return YES;
}

NSLog(@"Old could not be trashed or removed %@: %@", path, localError.localizedDescription);
if (error != nil)
{
*error = localError;
}

return NO;
}

- (void)moveTorrentDataFileTo:(NSString*)folder
Expand Down