@@ -163,15 +163,12 @@ static dispatch_queue_t RCTGetMethodQueue()
163163}
164164
165165
166- NSString *OldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
166+ NSString *const RCTOldStorageDirectory = @" RNCAsyncLocalStorage_V1" ;
167167/* *
168168 * Creates an NSException used during Storage Directory Migration.
169169 */
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 : @" " );
175172}
176173
177174/* *
@@ -184,24 +181,24 @@ static void RCTStorageDirectoryMigrationCheck() {
184181 NSError *error;
185182 BOOL isDir;
186183 // 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) {
188185 // Check if the new storage directory location already exists
189186 BOOL newStorageDirectoryExists = [[NSFileManager defaultManager ] fileExistsAtPath: RCTGetStorageDirectory () isDirectory: &isDir];
190187 if (newStorageDirectoryExists) {
191188 // If the new storage directory location already exists, remove existing directory
192189 newStorageDirectoryExists = !([[NSFileManager defaultManager ] removeItemAtPath: RCTGetStorageDirectory () error: &error]);
193190 if (newStorageDirectoryExists) {
194- @throw RCTStorageDirectionMigrationException (@" Failed to clear pre-existing storage directory" , error);
191+ RCTStorageDirectoryMigrationLogError (@" Failed to clear pre-existing storage directory" , error);
195192 }
196193 }
197194 if (!newStorageDirectoryExists) {
198195 // 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);
201198 } else {
202199 // 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);
205202 }
206203 }
207204 }
@@ -220,7 +217,7 @@ @implementation RNCAsyncStorage
220217}
221218
222219+ (BOOL )requiresMainQueueSetup {
223- return YES ;
220+ return NO ;
224221}
225222
226223- (instancetype )init
@@ -436,7 +433,7 @@ - (NSDictionary *)_writeEntry:(NSArray<NSString *> *)entry changedManifest:(BOOL
436433}
437434
438435RCT_EXPORT_METHOD (multiMerge:(NSArray <NSArray <NSString *> *> *)kvPairs
439- callback:(RCTResponseSenderBlock)callback)
436+ callback:(RCTResponseSenderBlock)callback)
440437{
441438 NSDictionary *errorOut = [self _ensureSetup ];
442439 if (errorOut) {
@@ -521,3 +518,4 @@ - (NSDictionary *)_writeEntry:(NSArray<NSString *> *)entry changedManifest:(BOOL
521518}
522519
523520@end
521+
0 commit comments