[SQLite Store] Add type checks to add string/art
String and art adder functions now perform type checks, in case of memory errors that somehow result in classes changing type. Which in itself is a strange thing to happen. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
e69ddb3578
commit
2c7285382c
|
@ -536,10 +536,10 @@ NSURL *_Nonnull urlForPath(NSString *_Nullable path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface SQLiteStore (Private)
|
@interface SQLiteStore (Private)
|
||||||
- (NSString *_Nullable)addString:(NSString *_Nullable)string returnId:(int64_t *_Nonnull)stringId;
|
- (NSString *_Nullable)addString:(id _Nullable)string returnId:(int64_t *_Nonnull)stringId;
|
||||||
- (NSString *_Nonnull)getString:(int64_t)stringId;
|
- (NSString *_Nonnull)getString:(int64_t)stringId;
|
||||||
- (void)removeString:(int64_t)stringId;
|
- (void)removeString:(int64_t)stringId;
|
||||||
- (NSData *_Nullable)addArt:(NSData *_Nullable)art returnId:(int64_t *_Nonnull)artId;
|
- (NSData *_Nullable)addArt:(id _Nullable)art returnId:(int64_t *_Nonnull)artId;
|
||||||
- (NSData *_Nonnull)getArt:(int64_t)artId;
|
- (NSData *_Nonnull)getArt:(int64_t)artId;
|
||||||
- (void)removeArt:(int64_t)artId;
|
- (void)removeArt:(int64_t)artId;
|
||||||
- (int64_t)addTrack:(PlaylistEntry *_Nonnull)track;
|
- (int64_t)addTrack:(PlaylistEntry *_Nonnull)track;
|
||||||
|
@ -772,8 +772,19 @@ static SQLiteStore *g_sharedStore = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)addString:(NSString *)string returnId:(int64_t *_Nonnull)stringId {
|
- (NSString *)addString:(id _Nullable)inputObj returnId:(int64_t *_Nonnull)stringId {
|
||||||
*stringId = -1;
|
*stringId = -1;
|
||||||
|
|
||||||
|
if(!inputObj) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *string = nil;
|
||||||
|
|
||||||
|
if([inputObj isKindOfClass:[NSString class]]) {
|
||||||
|
string = (NSString *)inputObj;
|
||||||
|
}
|
||||||
|
|
||||||
if(!string || [string length] == 0) {
|
if(!string || [string length] == 0) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
@ -924,8 +935,19 @@ static SQLiteStore *g_sharedStore = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSData *_Nullable)addArt:(NSData *_Nullable)art returnId:(int64_t *_Nonnull)artId {
|
- (NSData *_Nullable)addArt:(id _Nullable)inputObj returnId:(int64_t *_Nonnull)artId {
|
||||||
*artId = -1;
|
*artId = -1;
|
||||||
|
|
||||||
|
if(!inputObj) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSData *art = nil;
|
||||||
|
|
||||||
|
if([inputObj isKindOfClass:[NSData class]]) {
|
||||||
|
art = (NSData *)inputObj;
|
||||||
|
}
|
||||||
|
|
||||||
if(!art || [art length] == 0) {
|
if(!art || [art length] == 0) {
|
||||||
return art;
|
return art;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue