From 75de61366d2193e33208a165ec35137655e0116d Mon Sep 17 00:00:00 2001 From: "Dr. Sergey Pogodin" Date: Thu, 30 May 2024 13:10:20 +0200 Subject: [PATCH] v0.26.0: Misc improvements on top of the PR #47 --- example/ios/Podfile.lock | 6 +++--- .../ios/ReactNativeFsExample.xcodeproj/project.pbxproj | 10 ++++++++-- ios/ReactNativeFs.h | 8 ++++---- ios/ReactNativeFs.mm | 9 +++------ package.json | 2 +- src/index.ts | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 04266f7b..d9d33bba 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost (1.83.0) - DoubleConversion (1.1.6) - - dr-pogodin-react-native-fs (2.25.1): + - dr-pogodin-react-native-fs (2.26.0): - DoubleConversion - glog - hermes-engine @@ -1391,8 +1391,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: d3f49c53809116a5d38da093a8aa78bf551aed09 DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5 - dr-pogodin-react-native-fs: 1b8692d91b0af367bcae2acd834c48b609c6fc36 - dr-pogodin-react-native-static-server: d93f2556a2ac75007d784bb90d088385360df8d4 + dr-pogodin-react-native-fs: 043d4daed4fb348baddccba7bc98dee7ea7a4b91 + dr-pogodin-react-native-static-server: 064d84bba53f863504c6ea874549ea5a70405c42 FBLazyVector: 898d14d17bf19e2435cafd9ea2a1033efe445709 fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 diff --git a/example/ios/ReactNativeFsExample.xcodeproj/project.pbxproj b/example/ios/ReactNativeFsExample.xcodeproj/project.pbxproj index b659772f..45aa7bbe 100644 --- a/example/ios/ReactNativeFsExample.xcodeproj/project.pbxproj +++ b/example/ios/ReactNativeFsExample.xcodeproj/project.pbxproj @@ -598,7 +598,10 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = true; @@ -670,7 +673,10 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = true; diff --git a/ios/ReactNativeFs.h b/ios/ReactNativeFs.h index c348bf95..5ad79d81 100644 --- a/ios/ReactNativeFs.h +++ b/ios/ReactNativeFs.h @@ -25,7 +25,7 @@ namespace JS { struct MkdirOptionsT { std::optional NSURLIsExcludedFromBackupKey() const { - return _v[@"NSURLIsExcludedFromBackupKey"]; + return [_v[@"NSURLIsExcludedFromBackupKey"] boolValue]; } NSString *NSFileProtectionKey() const { return _v[@"NSFileProtectionKey"]; @@ -81,15 +81,15 @@ namespace JS { NSString *toUrl() const { return _v[@"toUrl"]; } std::optional binaryStreamOnly() const { - return ((NSNumber*)_v[@"binaryStreamOnly"]).boolValue; + return [_v[@"binaryStreamOnly"] boolValue]; } id files() const { return _v[@"files"]; } id _Nullable headers() const { return _v[@"headers"]; } id _Nullable fields() const { return _v[@"fields"]; } NSString *method() const { return _v[@"method"]; } - bool hasBeginCallback() const { return _v[@"hasBeginCallback"]; } - bool hasProgressCallback() const { return _v[@"hasProgressCallback"]; } + bool hasBeginCallback() const { return [_v[@"hasBeginCallback"] boolValue]; } + bool hasProgressCallback() const { return [_v[@"hasProgressCallback"] boolValue]; } NativeUploadFileOptionsT(NSDictionary *const v) : _v(v) {} private: diff --git a/ios/ReactNativeFs.mm b/ios/ReactNativeFs.mm index 94eb505a..4e70bbe6 100644 --- a/ios/ReactNativeFs.mm +++ b/ios/ReactNativeFs.mm @@ -548,12 +548,9 @@ - (instancetype) init params.toFile = options.toFile(); NSDictionary* headers = options.headers(); params.headers = headers; - NSNumber* background = [NSNumber numberWithBool:options.background()]; - params.background = [background boolValue]; - NSNumber* discretionary = [NSNumber numberWithBool:options.discretionary()]; - params.discretionary = [discretionary boolValue]; - NSNumber* cacheable = [NSNumber numberWithBool:options.cacheable()]; - params.cacheable = [cacheable boolValue]; + params.background = options.background(); + params.discretionary = options.discretionary(); + params.cacheable = options.cacheable(); NSNumber* progressInterval= [NSNumber numberWithDouble:options.progressInterval()]; params.progressInterval = progressInterval; NSNumber* progressDivider = [NSNumber numberWithDouble:options.progressDivider()]; diff --git a/package.json b/package.json index f4fd1705..00f75f4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dr.pogodin/react-native-fs", - "version": "2.25.3", + "version": "2.26.0", "description": "Native filesystem access for React Native", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/index.ts b/src/index.ts index ccf402bd..30ad1f34 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,7 +173,7 @@ export function downloadFile(options: DownloadFileOptionsT): { toFile: normalizeFilePath(options.toFile), background: !!options.background, backgroundTimeout: options.backgroundTimeout || 3600000, // 1 hour - cacheable: options.cacheable === undefined ? true : options.cacheable, + cacheable: options.cacheable ?? true, connectionTimeout: options.connectionTimeout || 5000, discretionary: !!options.discretionary, headers: options.headers || {},