Skip to content

Commit 10c8001

Browse files
committed
update ios
1 parent 7f9582c commit 10c8001

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

ios/Fula.swift

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,13 +1569,32 @@ class FulaModule: NSObject {
15691569

15701570
@objc(getFolderSize:withResolver:withRejecter:)
15711571
func getFolderSize(folderPath: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
1572+
// Validate the folder path
1573+
guard !folderPath.isEmpty else {
1574+
reject("ERR_INVALID_PATH", "The folder path is empty.", nil)
1575+
return
1576+
}
1577+
15721578
do {
1573-
let result = try self.fula!.getFolderSize(folderPath)
1574-
let resultString = result.toUTF8String()!
1575-
resolve(resultString)
1579+
// Ensure fula is not nil before calling getFolderSize
1580+
guard let fula = self.fula else {
1581+
reject("ERR_FULA", "Fula instance is not initialized.", nil)
1582+
return
1583+
}
1584+
1585+
// Attempt to get the folder size
1586+
let result = try fula.getFolderSize(folderPath)
1587+
1588+
// Convert the result to a UTF-8 string safely
1589+
if let resultString = result.toUTF8String() {
1590+
resolve(resultString)
1591+
} else {
1592+
reject("ERR_CONVERSION", "Failed to convert result to UTF-8 string.", nil)
1593+
}
15761594
} catch let error {
1577-
print("getFolderSize", error.localizedDescription)
1578-
reject("ERR_FULA", "getFolderSize", error)
1595+
// Log and reject with detailed error information
1596+
print("getFolderSize error:", error.localizedDescription)
1597+
reject("ERR_FULA", "Failed to get folder size: \(error.localizedDescription)", error)
15791598
}
15801599
}
15811600

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@functionland/react-native-fula",
3-
"version": "1.54.33",
3+
"version": "1.54.34",
44
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)