Skip to content

Conversation

chrisbobbe
Copy link
Contributor

This seems to be a move / rename, not something more disruptive like
a rewrite. In fact, I don't expect this to be any more disruptive
than taking the next patch version in the library's natural
progression. If I add the new-location package at its first
available version, 1.13.0, and I keep the old one at its latest
available (and the one we're on currently), 1.12.1, I see very few
differences between them:

git diff --no-index node_modules/@react-native-{community,async-storage}/async-storage
diff --git node_modules/@react-native-community/async-storage/README.md node_modules/@react-native-async-storage/async-storage/README.md
index a96bb58d3..bab406607 100644
--- node_modules/@react-native-community/async-storage/README.md
+++ node_modules/@react-native-async-storage/async-storage/README.md
@@ -14,7 +14,7 @@ An asynchronous, unencrypted, persistent, key-value storage system for React Nat
 
 ## Getting Started
 
-Head over to [documentation](https://react-native-community.github.io/async-storage/) to learn more.
+Head over to [documentation](https://react-native-async-storage.github.io/async-storage/docs/install) to learn more.
 
 
 ## Contribution
diff --git node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.m node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.m
index 8b20cc2f6..6a268fb75 100644
--- node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.m
+++ node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.m
@@ -34,6 +34,26 @@
   }
 }
 
+static BOOL RCTAsyncStorageSetExcludedFromBackup(NSString* path, NSNumber* isExcluded)
+{
+    NSFileManager *fileManager = [[NSFileManager alloc] init];
+    
+    BOOL isDir;
+    BOOL exists = [fileManager fileExistsAtPath:path isDirectory:&isDir];
+    BOOL success = false;
+    
+    if (isDir && exists) {
+        NSURL* pathUrl = [NSURL fileURLWithPath:path];
+        NSError *error = nil;
+        success = [pathUrl setResourceValue:isExcluded forKey:NSURLIsExcludedFromBackupKey error:&error];
+
+        if (!success) {
+            NSLog(@"Could not exclude AsyncStorage dir from backup %@", error);
+        }
+    }
+    return success;
+}
+
 static void RCTAppendError(NSDictionary *error, NSMutableArray<NSDictionary *> **errors)
 {
   if (error && errors) {
@@ -393,6 +413,14 @@ - (NSDictionary *)_ensureSetup
   }
 
   if (!_haveSetup) {
+    // iCloud backup exclusion
+    NSNumber* isExcludedFromBackup = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTAsyncStorageExcludeFromBackup"];
+    if (isExcludedFromBackup == nil) {
+      // by default, we want to exclude AsyncStorage data from backup
+      isExcludedFromBackup = @YES;
+    }
+    RCTAsyncStorageSetExcludedFromBackup(RCTCreateStorageDirectoryPath(RCTStorageDirectory), isExcludedFromBackup);
+
     NSDictionary *errorOut = nil;
     NSString *serialized = RCTReadFile(RCTCreateStorageDirectoryPath(RCTGetManifestFilePath()), RCTManifestFileName, &errorOut);
     if (!serialized) {
diff --git node_modules/@react-native-community/async-storage/package.json node_modules/@react-native-async-storage/async-storage/package.json
index 0080fb46c..19d248822 100644
--- node_modules/@react-native-community/async-storage/package.json
+++ node_modules/@react-native-async-storage/async-storage/package.json
@@ -1,6 +1,6 @@
 {
-  "name": "@react-native-community/async-storage",
-  "version": "1.12.1",
+  "name": "@react-native-async-storage/async-storage",
+  "version": "1.13.0",
   "description": "Asynchronous, persistent, key-value storage system for React Native.",
   "main": "lib/commonjs/index.js",
   "module": "lib/module/index.js",
diff --git node_modules/@react-native-community/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj
index df6ea9332..a5373c32c 100644
--- node_modules/@react-native-community/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj
+++ node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj
@@ -146,6 +146,7 @@
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
   </ImportGroup>
+  <Target Name="Deploy"/>
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
       <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
@@ -153,4 +154,4 @@
     <Error Condition="!Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
     <Error Condition="!Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.190730.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
   </Target>
-</Project>
\ No newline at end of file
+</Project>

And those differences seem like a good match for the changelog entry for 1.13.0: https://github.com/react-native-async-storage/async-storage/releases/tag/v1.13.0

Fixes: #4890

@chrisbobbe chrisbobbe added the dependencies Pull requests that update a dependency file label Jul 12, 2021
@chrisbobbe chrisbobbe requested review from gnprice and WesleyAC July 12, 2021 21:54
@gnprice
Copy link
Member

gnprice commented Aug 4, 2021

All looks good! Two comments, both just in commit messages:

[1] For the output, see <insert link here>

I think you intended this to be a link to this PR 😄

deps: Remove caret on @react-native-async-storage/async-storage.

I think you mean add caret, right? (Or "remove pinning", except there isn't a great concise jargon term in that direction because "pinning" is often used to mean the function yarn.lock performs.)

Please merge as will after fixing those.

… move.

This seems to be a move / rename, not something more disruptive like
a rewrite. In fact, I don't expect this to be any more disruptive
than taking the next patch version in the library's natural
progression. If I add the new-location package at its first
available version, 1.13.0, and I keep the old one at its latest
available (and the one we've been on), 1.12.1, I see very few
differences between them [1]:

git diff --no-index \
  node_modules/@react-native-{community,async-storage}/async-storage

The package in its new location keeps the changelog entries from
when it was maintained at the old location. That changelog confirms
that 1.13.0 comes right after 1.12.1, and the 1.13.0 entry looks
like a match for what we saw in the `git diff --no-index` output.

So this shouldn't be disruptive at all, unless 1.13.0 has
unannounced breaking changes.

[1] For the output, see the PR description at
    zulip#4894 (comment).
This takes us to v1.15.5, the current latest. No breaking changes
are announced in the changelog [1], but 1.13.3 does announce this:

> After upgrading to v1.13.3+, remember to:
>
> - remove Pods directory (ios/Pods)
> - clean build directory through Xcode (in menu: Product -> Clean
>   Build Folder)
> - install dependencies again (`pod install`)

All this didn't seem obviously necessary (except `pod install`,
which we always do), but I did it anyway.

v1.13.4 gets us @react-native-async-storage/async-storagefb0ce97e3,
which we'll need for the RN v0.64 upgrade, zulip#4426.

[1] https://github.com/react-native-async-storage/async-storage/releases

Fixes: zulip#4890
@chrisbobbe chrisbobbe force-pushed the pr-async-storage-move branch from 00fe105 to 2c559b1 Compare August 4, 2021 15:41
@chrisbobbe chrisbobbe merged commit 2c559b1 into zulip:master Aug 4, 2021
@chrisbobbe
Copy link
Contributor Author

Please merge as will after fixing those.

Done, thanks for the review!

@chrisbobbe chrisbobbe deleted the pr-async-storage-move branch August 4, 2021 16:09
@chrisbobbe chrisbobbe mentioned this pull request Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file P1 high-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to @react-native-async-storage/async-storage.
2 participants