Compare commits

...

4 commits

Author SHA1 Message Date
Christopher Snowhill
e852fdfccd Project Fix: Remove non-existent paths
These referenced libMAD, which has been replaced. The effect was
essentially harmless, except for a compile time warning.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-09 23:57:12 -07:00
Christopher Snowhill
2d0729b2c5 Bug Fix: Set URL object before attempting to log
This was logging a potentially unassigned variable. Oops.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-09 23:56:08 -07:00
Christopher Snowhill
ba572f3035 Bug Check: Return silence instead of null URL
This is technically an error condition, but handle it in a non-crashy
way.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-09 23:55:38 -07:00
Christopher Snowhill
6b2adb8a88 Bug Fixes: Some more generic NULL URL checks
Also catch some invalid URLs in the database.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-09 23:54:42 -07:00
5 changed files with 20 additions and 21 deletions

View file

@ -399,7 +399,7 @@ extern NSMutableDictionary<NSString *, AlbumArtwork *> *kArtworkDictionary;
NSURL *_Nullable urlForPath(NSString *_Nullable path) { NSURL *_Nullable urlForPath(NSString *_Nullable path) {
if(!path || ![path length]) { if(!path || ![path length]) {
return nil; return [NSURL URLWithString:@"silence://10"];
} }
NSRange protocolRange = [path rangeOfString:@"://"]; NSRange protocolRange = [path rangeOfString:@"://"];

View file

@ -392,7 +392,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
for(url in urls) { for(url in urls) {
id<SentrySpan> pathTask = [sandboxTask startChildWithOperation:@"Process one folder" description:[NSString stringWithFormat:@"Processing file or folder: %@", url]]; id<SentrySpan> pathTask = [sandboxTask startChildWithOperation:@"Process one folder" description:[NSString stringWithFormat:@"Processing file or folder: %@", url]];
@try { @try {
if(!url) continue;
if([url isFileURL]) { if([url isFileURL]) {
if(![url path]) continue;
BOOL isDir; BOOL isDir;
if([[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:&isDir]) { if([[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:&isDir]) {
if(isDir == YES) { if(isDir == YES) {
@ -419,6 +421,7 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
} }
} else { } else {
// Non-file URL.. // Non-file URL..
if(![url absoluteString]) continue;
[expandedURLs setValue:url forKey:[PlaylistLoader keyForPath:[url absoluteString]]]; [expandedURLs setValue:url forKey:[PlaylistLoader keyForPath:[url absoluteString]]];
} }
@ -470,11 +473,11 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
id<SentrySpan> innerTask = nil; id<SentrySpan> innerTask = nil;
NSURL *url = nil; NSURL *url = nil;
@try { @try {
url = obj;
if(containerTask) { if(containerTask) {
pathTask = [containerTask startChildWithOperation:@"Process path as container" description:[NSString stringWithFormat:@"Checking if file is container: %@", url]]; pathTask = [containerTask startChildWithOperation:@"Process path as container" description:[NSString stringWithFormat:@"Checking if file is container: %@", url]];
} }
url = obj;
[lock lock]; [lock lock];
if([uniqueURLs containsObject:url]) { if([uniqueURLs containsObject:url]) {
[lock unlock]; [lock unlock];
@ -810,7 +813,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path);
- (void)loadInfoForEntries:(NSArray *)entries { - (void)loadInfoForEntries:(NSArray *)entries {
NSMutableDictionary *queueThisJob = [[NSMutableDictionary alloc] init]; NSMutableDictionary *queueThisJob = [[NSMutableDictionary alloc] init];
for(PlaylistEntry *pe in entries) { for(PlaylistEntry *pe in entries) {
if(!pe || !pe.urlString || pe.deLeted || pe.metadataLoaded) continue; if(!pe || !pe.urlString || ![pe.urlString length] || pe.deLeted || pe.metadataLoaded) continue;
NSString *path = pe.urlString; NSString *path = pe.urlString;
NSMutableArray *entrySet = [queueThisJob objectForKey:path]; NSMutableArray *entrySet = [queueThisJob objectForKey:path];
@ -1160,7 +1163,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path);
NSMutableIndexSet *pruneSet = [[NSMutableIndexSet alloc] init]; NSMutableIndexSet *pruneSet = [[NSMutableIndexSet alloc] init];
NSUInteger index = 0; NSUInteger index = 0;
for(PlaylistEntry *pe in resultsCopy) { for(PlaylistEntry *pe in resultsCopy) {
if(pe.deLeted || !pe.urlString || [pe.urlString length] < 1) { if(pe.deLeted || !pe.urlString || ![pe.urlString length]) {
[pruneSet addIndex:index]; [pruneSet addIndex:index];
[moc deleteObject:pe]; [moc deleteObject:pe];
} }

View file

@ -10,6 +10,8 @@
#import "SandboxBroker.h" #import "SandboxBroker.h"
#import "Logging.h"
@implementation FileSource @implementation FileSource
+ (void)initialize { + (void)initialize {
@ -34,6 +36,10 @@
sbHandle = [sandboxBroker beginFolderAccess:url]; sbHandle = [sandboxBroker beginFolderAccess:url];
NSString *path = [url path]; NSString *path = [url path];
if(!path) {
ALog(@"Invalid URL: %@", url);
return NO;
}
fex_type_t type; fex_type_t type;
fex_err_t error = fex_identify_file(&type, [path UTF8String]); fex_err_t error = fex_identify_file(&type, [path UTF8String]);

View file

@ -40,6 +40,7 @@
8307D31B2860722C000FF8EB /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../Utils/SandboxBroker.h; sourceTree = "<group>"; }; 8307D31B2860722C000FF8EB /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../Utils/SandboxBroker.h; sourceTree = "<group>"; };
8335FF6817FF765A002D8DD2 /* File_Extractor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = File_Extractor.xcodeproj; path = ../../Frameworks/File_Extractor/File_Extractor.xcodeproj; sourceTree = "<group>"; }; 8335FF6817FF765A002D8DD2 /* File_Extractor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = File_Extractor.xcodeproj; path = ../../Frameworks/File_Extractor/File_Extractor.xcodeproj; sourceTree = "<group>"; };
834A42AD287AF25600EB9D9B /* AudioChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioChunk.h; path = ../../Audio/Chain/AudioChunk.h; sourceTree = "<group>"; }; 834A42AD287AF25600EB9D9B /* AudioChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioChunk.h; path = ../../Audio/Chain/AudioChunk.h; sourceTree = "<group>"; };
835F15B82DF80DE1008C7054 /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = /Users/chris/Source/Repos/cog/Utils/Logging.h; sourceTree = "<absolute>"; };
83747C4F2862DD2F0021245F /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = "<group>"; }; 83747C4F2862DD2F0021245F /* Shared.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Shared.xcconfig; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* FileSource.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FileSource.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B6048680CD000E48DA /* FileSource.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FileSource.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -93,6 +94,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
834A42AD287AF25600EB9D9B /* AudioChunk.h */, 834A42AD287AF25600EB9D9B /* AudioChunk.h */,
835F15B82DF80DE1008C7054 /* Logging.h */,
8307D31B2860722C000FF8EB /* SandboxBroker.h */, 8307D31B2860722C000FF8EB /* SandboxBroker.h */,
17ADB4080B979A8A00257CA2 /* Plugin.h */, 17ADB4080B979A8A00257CA2 /* Plugin.h */,
17ADB4180B979AEB00257CA2 /* FileSource.h */, 17ADB4180B979AEB00257CA2 /* FileSource.h */,

View file

@ -299,17 +299,11 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = ../../ThirdParty/libid3tag/include;
../../ThirdParty/libmad/include,
../../ThirdParty/libid3tag/include,
);
INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSPrincipalClass = ""; INFOPLIST_KEY_NSPrincipalClass = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = ../../ThirdParty/libid3tag/lib;
../../ThirdParty/libmad/lib,
../../ThirdParty/libid3tag/lib,
);
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = co.losno.MAD; PRODUCT_BUNDLE_IDENTIFIER = co.losno.MAD;
@ -327,17 +321,11 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES; DEAD_CODE_STRIPPING = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = ../../ThirdParty/libid3tag/include;
../../ThirdParty/libmad/include,
../../ThirdParty/libid3tag/include,
);
INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSPrincipalClass = ""; INFOPLIST_KEY_NSPrincipalClass = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = ../../ThirdParty/libid3tag/lib;
../../ThirdParty/libmad/lib,
../../ThirdParty/libid3tag/lib,
);
MACOSX_DEPLOYMENT_TARGET = 10.13; MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = co.losno.MAD; PRODUCT_BUNDLE_IDENTIFIER = co.losno.MAD;