From 388c40cd41e2bbbc3fe3e3336e32a4dc64fa84a4 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 26 Oct 2018 16:06:18 +0200 Subject: LicenseHandler(addLicense:): Delete license file instead of trashing it The trash/recycle method wasn't working because it was asynchronous. As a result, the file never got moved. Using `removeItemAtURL:error:` does work, and is available starting in OS 10.6. But I still don't like the idea of forcibly deleting files. What if the user licenses the program and deletes their license file, then somehow gets their only local copy deleted? Need to work out a different way of doing this. --- DomeKey/LicenseHandler.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DomeKey/LicenseHandler.m b/DomeKey/LicenseHandler.m index c6e0e9c..0421e2e 100644 --- a/DomeKey/LicenseHandler.m +++ b/DomeKey/LicenseHandler.m @@ -51,13 +51,13 @@ static NSString * const LICENSE_FILE_NAME = @"license.plist"; else { [self printInvalidLicenseMessage]; - [[NSWorkspace sharedWorkspace] - recycleURLs:[NSArray arrayWithObject:[self licensePath]] - completionHandler:^(NSDictionary *newURLs, NSError *error) { - if (error) { - eprintf("%s\n", [[error localizedDescription] UTF8String]); - } - }]; + BOOL removed = [[NSFileManager defaultManager] + removeItemAtURL:[self licensePath] + error:&error]; + + if (!removed) { + eprintf("%s\n", [[error localizedDescription] UTF8String]); + } } // Copy license file into path -- cgit v1.2.3