From 10c8001f1478367ae48d6a6e91ff16698420dcfc Mon Sep 17 00:00:00 2001 From: ehsan shariati Date: Mon, 2 Dec 2024 01:02:00 -0500 Subject: [PATCH] update ios --- ios/Fula.swift | 29 ++++++++++++++++++++++++----- package.json | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ios/Fula.swift b/ios/Fula.swift index 24a3ed0..656083b 100644 --- a/ios/Fula.swift +++ b/ios/Fula.swift @@ -1569,13 +1569,32 @@ class FulaModule: NSObject { @objc(getFolderSize:withResolver:withRejecter:) func getFolderSize(folderPath: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void { + // Validate the folder path + guard !folderPath.isEmpty else { + reject("ERR_INVALID_PATH", "The folder path is empty.", nil) + return + } + do { - let result = try self.fula!.getFolderSize(folderPath) - let resultString = result.toUTF8String()! - resolve(resultString) + // Ensure fula is not nil before calling getFolderSize + guard let fula = self.fula else { + reject("ERR_FULA", "Fula instance is not initialized.", nil) + return + } + + // Attempt to get the folder size + let result = try fula.getFolderSize(folderPath) + + // Convert the result to a UTF-8 string safely + if let resultString = result.toUTF8String() { + resolve(resultString) + } else { + reject("ERR_CONVERSION", "Failed to convert result to UTF-8 string.", nil) + } } catch let error { - print("getFolderSize", error.localizedDescription) - reject("ERR_FULA", "getFolderSize", error) + // Log and reject with detailed error information + print("getFolderSize error:", error.localizedDescription) + reject("ERR_FULA", "Failed to get folder size: \(error.localizedDescription)", error) } } diff --git a/package.json b/package.json index 6da8fa0..ffc91db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@functionland/react-native-fula", - "version": "1.54.33", + "version": "1.54.34", "description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs", "main": "lib/commonjs/index", "module": "lib/module/index",