@@ -175,15 +175,12 @@ static dispatch_queue_t RCTGetMethodQueue()
175
175
}
176
176
177
177
178
- NSString *OldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
178
+ NSString *const RCTOldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
179
179
/* *
180
180
* Creates an NSException used during Storage Directory Migration.
181
181
*/
182
- static NSException *RCTStorageDirectionMigrationException (NSString *reason, NSError *error) {
183
- NSMutableString *reasonString = [[NSMutableString alloc ] initWithString: reason];
184
- [reasonString appendString: @" - " ];
185
- [reasonString appendString: [error description ]];
186
- return [[NSException alloc ] initWithName: @" RCTStorageDirectoryMigrationFailure" reason: reasonString userInfo: nil ];
182
+ static void RCTStorageDirectoryMigrationLogError (NSString *reason, NSError *error) {
183
+ NSLog (@" %@ : %@ " , reason, error ? error.description : @" " );
187
184
}
188
185
189
186
/* *
@@ -196,24 +193,24 @@ static void RCTStorageDirectoryMigrationCheck() {
196
193
NSError *error;
197
194
BOOL isDir;
198
195
// If the old directory exists, it means we need to migrate data to the new directory
199
- if ([[NSFileManager defaultManager ] fileExistsAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) isDirectory: &isDir] && isDir) {
196
+ if ([[NSFileManager defaultManager ] fileExistsAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) isDirectory: &isDir] && isDir) {
200
197
// Check if the new storage directory location already exists
201
198
BOOL newStorageDirectoryExists = [[NSFileManager defaultManager ] fileExistsAtPath: RCTGetStorageDirectory () isDirectory: &isDir];
202
199
if (newStorageDirectoryExists) {
203
200
// If the new storage directory location already exists, remove existing directory
204
201
newStorageDirectoryExists = !([[NSFileManager defaultManager ] removeItemAtPath: RCTGetStorageDirectory () error: &error]);
205
202
if (newStorageDirectoryExists) {
206
- @throw RCTStorageDirectionMigrationException (@" Failed to clear pre-existing storage directory" , error);
203
+ RCTStorageDirectoryMigrationLogError (@" Failed to clear pre-existing storage directory" , error);
207
204
}
208
205
}
209
206
if (!newStorageDirectoryExists) {
210
207
// If new storage direction doesn't exist, copy old storage directory to new location
211
- if (![[NSFileManager defaultManager ] copyItemAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) toPath: RCTGetStorageDirectory () error: &error]) {
212
- @throw RCTStorageDirectionMigrationException (@" Failed to copy old storage directory to new storage directory" , error);
208
+ if (![[NSFileManager defaultManager ] copyItemAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) toPath: RCTGetStorageDirectory () error: &error]) {
209
+ RCTStorageDirectoryMigrationLogError (@" Failed to copy old storage directory to new storage directory" , error);
213
210
} else {
214
211
// If copying succeeds, remove old storage directory
215
- [[NSFileManager defaultManager ] removeItemAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) error: &error];
216
- if (error) @throw RCTStorageDirectionMigrationException (@" Failed to remove old storage directory after migration" , error);
212
+ [[NSFileManager defaultManager ] removeItemAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) error: &error];
213
+ if (error) RCTStorageDirectoryMigrationLogError (@" Failed to remove old storage directory after migration" , error);
217
214
}
218
215
}
219
216
}
@@ -232,7 +229,7 @@ @implementation RNCAsyncStorage
232
229
}
233
230
234
231
+ (BOOL )requiresMainQueueSetup {
235
- return YES ;
232
+ return NO ;
236
233
}
237
234
238
235
- (instancetype )init
@@ -506,7 +503,7 @@ - (BOOL)_passthroughDelegate
506
503
}
507
504
508
505
RCT_EXPORT_METHOD (multiMerge:(NSArray <NSArray <NSString *> *> *)kvPairs
509
- callback:(RCTResponseSenderBlock)callback)
506
+ callback:(RCTResponseSenderBlock)callback)
510
507
{
511
508
if (self.delegate != nil ) {
512
509
NSMutableArray <NSString *> *keys = [NSMutableArray arrayWithCapacity: kvPairs.count];
@@ -640,3 +637,4 @@ - (BOOL)_passthroughDelegate
640
637
}
641
638
642
639
@end
640
+
0 commit comments