@@ -163,15 +163,12 @@ static dispatch_queue_t RCTGetMethodQueue()
163
163
}
164
164
165
165
166
- NSString *OldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
166
+ NSString *const RCTOldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
167
167
/* *
168
168
* Creates an NSException used during Storage Directory Migration.
169
169
*/
170
- static NSException *RCTStorageDirectionMigrationException (NSString *reason, NSError *error) {
171
- NSMutableString *reasonString = [[NSMutableString alloc ] initWithString: reason];
172
- [reasonString appendString: @" - " ];
173
- [reasonString appendString: [error description ]];
174
- return [[NSException alloc ] initWithName: @" RCTStorageDirectoryMigrationFailure" reason: reasonString userInfo: nil ];
170
+ static void RCTStorageDirectoryMigrationLogError (NSString *reason, NSError *error) {
171
+ NSLog (@" %@ : %@ " , reason, error ? error.description : @" " );
175
172
}
176
173
177
174
/* *
@@ -184,24 +181,24 @@ static void RCTStorageDirectoryMigrationCheck() {
184
181
NSError *error;
185
182
BOOL isDir;
186
183
// If the old directory exists, it means we need to migrate data to the new directory
187
- if ([[NSFileManager defaultManager ] fileExistsAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) isDirectory: &isDir] && isDir) {
184
+ if ([[NSFileManager defaultManager ] fileExistsAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) isDirectory: &isDir] && isDir) {
188
185
// Check if the new storage directory location already exists
189
186
BOOL newStorageDirectoryExists = [[NSFileManager defaultManager ] fileExistsAtPath: RCTGetStorageDirectory () isDirectory: &isDir];
190
187
if (newStorageDirectoryExists) {
191
188
// If the new storage directory location already exists, remove existing directory
192
189
newStorageDirectoryExists = !([[NSFileManager defaultManager ] removeItemAtPath: RCTGetStorageDirectory () error: &error]);
193
190
if (newStorageDirectoryExists) {
194
- @throw RCTStorageDirectionMigrationException (@" Failed to clear pre-existing storage directory" , error);
191
+ RCTStorageDirectoryMigrationLogError (@" Failed to clear pre-existing storage directory" , error);
195
192
}
196
193
}
197
194
if (!newStorageDirectoryExists) {
198
195
// If new storage direction doesn't exist, copy old storage directory to new location
199
- if (![[NSFileManager defaultManager ] copyItemAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) toPath: RCTGetStorageDirectory () error: &error]) {
200
- @throw RCTStorageDirectionMigrationException (@" Failed to copy old storage directory to new storage directory" , error);
196
+ if (![[NSFileManager defaultManager ] copyItemAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) toPath: RCTGetStorageDirectory () error: &error]) {
197
+ RCTStorageDirectoryMigrationLogError (@" Failed to copy old storage directory to new storage directory" , error);
201
198
} else {
202
199
// If copying succeeds, remove old storage directory
203
- [[NSFileManager defaultManager ] removeItemAtPath: RCTCreateStorageDirectoryPath (OldStorageDirectory ) error: &error];
204
- if (error) @throw RCTStorageDirectionMigrationException (@" Failed to remove old storage directory after migration" , error);
200
+ [[NSFileManager defaultManager ] removeItemAtPath: RCTCreateStorageDirectoryPath (RCTOldStorageDirectory ) error: &error];
201
+ if (error) RCTStorageDirectoryMigrationLogError (@" Failed to remove old storage directory after migration" , error);
205
202
}
206
203
}
207
204
}
@@ -220,7 +217,7 @@ @implementation RNCAsyncStorage
220
217
}
221
218
222
219
+ (BOOL )requiresMainQueueSetup {
223
- return YES ;
220
+ return NO ;
224
221
}
225
222
226
223
- (instancetype )init
@@ -436,7 +433,7 @@ - (NSDictionary *)_writeEntry:(NSArray<NSString *> *)entry changedManifest:(BOOL
436
433
}
437
434
438
435
RCT_EXPORT_METHOD (multiMerge:(NSArray <NSArray <NSString *> *> *)kvPairs
439
- callback:(RCTResponseSenderBlock)callback)
436
+ callback:(RCTResponseSenderBlock)callback)
440
437
{
441
438
NSDictionary *errorOut = [self _ensureSetup ];
442
439
if (errorOut) {
@@ -521,3 +518,4 @@ - (NSDictionary *)_writeEntry:(NSArray<NSString *> *)entry changedManifest:(BOOL
521
518
}
522
519
523
520
@end
521
+
0 commit comments