1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-03-11 04:42:20 +00:00

Ensure no infinite loop if bookmark data is missing.

This commit is contained in:
Thomas Harte
2025-11-25 22:06:45 -05:00
parent 7db46f76e9
commit b0438c1ce1

View File

@@ -42,7 +42,7 @@ struct PermissionDelegate: public Storage::FileBundle::FileBundle::PermissionDel
NSString *bookmarkKey = [[url URLByDeletingLastPathComponent] absoluteString];
while(true) {
// If the file can already be read, no further action required.
// If the file exists can already be read, no further action required.
// That is, given that the macOS sandbox doesn't differentiate read/write access once permission is granted.
NSError *error;
NSFileHandle *file = [NSFileHandle fileHandleForReadingFromURL:url error:&error];
@@ -50,6 +50,8 @@ struct PermissionDelegate: public Storage::FileBundle::FileBundle::PermissionDel
return;
}
// TODO: if that file doesn't exist... try anything?
// Was failure to open due to permissions?
if(
error.domain != NSCocoaErrorDomain ||
@@ -79,6 +81,8 @@ struct PermissionDelegate: public Storage::FileBundle::FileBundle::PermissionDel
bookmarkDataIsStale:nil
error:nil];
[accessURL startAccessingSecurityScopedResource];
} else {
break;
}
}