From 27b4d215641f9397ef415cbb2acfc1275e6110ac Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Tue, 29 Jan 2019 09:11:22 -0800 Subject: [PATCH] Always write the manifest in multiRemove (#18613) Summary: RCTAsyncLocalStorage did not write the manifest after removing a value that was larger than RCTInlineValueThreshold. This meant that the values would still be on disk as null in the manifest.json, and if the app didn't do anything to make the manifest get written out again the null values would persist in the AsyncStorage and be returned by getAllKeys. We need to always write out the manifest.json even if the value is in the overflow storage files. Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. Fixes #9196. Not sure where the tests are for this? none. [IOS] [BUGFIX] [AsyncStorage] - Correctly remove keys of large values from AsyncStorage. tadeuzagallo nicklockwood dannycochran Pull Request resolved: https://github.com/facebook/react-native/pull/18613 Differential Revision: D13860820 Pulled By: cpojer fbshipit-source-id: ced1cd40273140335cd9b1f29fc1c1881ab8cebd --- React/Modules/RCTAsyncLocalStorage.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/React/Modules/RCTAsyncLocalStorage.m b/React/Modules/RCTAsyncLocalStorage.m index dff7d903f..c77fac403 100644 --- a/React/Modules/RCTAsyncLocalStorage.m +++ b/React/Modules/RCTAsyncLocalStorage.m @@ -423,10 +423,8 @@ RCT_EXPORT_METHOD(multiRemove:(NSArray *)keys NSString *filePath = [self _filePathForKey:key]; [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; [RCTGetCache() removeObjectForKey:key]; - // remove the key from manifest, but no need to mark as changed just for - // this, as the cost of checking again next time is negligible. - [_manifest removeObjectForKey:key]; - } else if (_manifest[key]) { + } + if (_manifest[key]) { changedManifest = YES; [_manifest removeObjectForKey:key]; }