Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/default-storage/ios/RNCAsyncStorage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,14 @@ - (BOOL)_passthroughDelegate

[_manifest removeAllObjects];
[RCTGetCache() removeAllObjects];
NSDictionary *error = RCTDeleteStorageDirectory();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler if we check whether error.code == NSFileNoSuchFileError in RCTDeleteStorageDirectory() and ignore it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it works and is also more clean, thanks for that.
I'm kinda new on Objective-C, I only return nil to ignore, if it was better to return another thing I could change again.

callback(@[RCTNullIfNil(error)]);

NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:RCTGetStorageDirectory()]) {
NSDictionary *error = RCTDeleteStorageDirectory();
callback(@[RCTNullIfNil(error)]);
} else {
callback(@[[NSNull null]]);
}
}

// clang-format off
Expand Down