From 353e7671080e2b6b3c144a024e6f9031c084b812 Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Sun, 4 Feb 2024 03:16:07 -0800 Subject: [PATCH] Skip items in themes directory with no data For example, directories. Fixes #2343 --- app/Theme.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Theme.m b/app/Theme.m index ae13f66a52..1321bcaa37 100644 --- a/app/Theme.m +++ b/app/Theme.m @@ -337,7 +337,12 @@ + (NSURL *)themesDirectory { + (NSArray *)userThemes { NSMutableArray *themes = [NSMutableArray new]; for (NSURL *file in [NSFileManager.defaultManager contentsOfDirectoryAtURL:self.themesDirectory includingPropertiesForKeys:nil options:0 error:nil]) { - Theme *theme = [[Theme alloc] initWithName:file.lastPathComponent.stringByDeletingPathExtension data:[NSData dataWithContentsOfURL:file]]; + NSData *data = [NSData dataWithContentsOfURL:file]; + if (!data) { + continue; + } + + Theme *theme = [[Theme alloc] initWithName:file.lastPathComponent.stringByDeletingPathExtension data:data]; if (theme) { [themes addObject:theme]; }