Skip to content

Commit

Permalink
update ios
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Dec 2, 2024
1 parent 7f9582c commit 10c8001
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions ios/Fula.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 10c8001

Please sign in to comment.