Skip to content

Commit edec1c7

Browse files
committed
added deleteDsLock
1 parent a429aab commit edec1c7

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,22 @@ public void newClient(String identityString, String storePath, String bloxAddr,
252252
});
253253
}
254254

255+
@ReactMethod
256+
public void deleteDsLock() {
257+
String lockFilePath = fulaConfig.getStorePath() + "/LOCK";
258+
Path lockFile = Paths.get(lockFilePath);
259+
try {
260+
if (Files.exists(lockFile)) {
261+
Files.delete(lockFile);
262+
Log.d("ReactNative", "Lock file deleted successfully.");
263+
} else {
264+
Log.d("ReactNative", "Lock file does not exist.");
265+
}
266+
} catch (Exception e) {
267+
Log.d("ReactNative", "Failed to delete lock file: " + e.getMessage());
268+
}
269+
}
270+
255271
@ReactMethod
256272
public void isReady(boolean filesystemCheck, Promise promise) {
257273
Log.d("ReactNative", "isReady started");

ios/Fula.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ @interface RCT_EXTERN_MODULE(FulaModule, NSObject)
231231
withResolver:(RCTPromiseResolveBlock)resolve
232232
withRejecter:(RCTPromiseRejectBlock)reject)
233233

234+
RCT_EXTERN_METHOD(deleteDsLock:(RCTPromiseResolveBlock)resolve
235+
withRejecter:(RCTPromiseRejectBlock)reject)
236+
234237
RCT_EXTERN_METHOD(replicateInPool:(NSArray *)cidArray
235238
withAccount:(NSString *)account
236239
withPoolID:(NSString *)poolIDStr

ios/Fula.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,26 @@ class FulaModule: NSObject {
12201220

12211221
}
12221222

1223+
@objc
1224+
func deleteDsLock(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
1225+
let lockFilePath = (fulaConfig.getStorePath() as NSString).appendingPathComponent("LOCK")
1226+
let fileManager = FileManager.default
1227+
1228+
do {
1229+
if fileManager.fileExists(atPath: lockFilePath) {
1230+
try fileManager.removeItem(atPath: lockFilePath)
1231+
NSLog("ReactNative: Lock file deleted successfully.")
1232+
resolve(true)
1233+
} else {
1234+
NSLog("ReactNative: Lock file does not exist.")
1235+
resolve(false) // Resolve with false if the file doesn't exist
1236+
}
1237+
} catch let error as NSError {
1238+
NSLog("ReactNative: Failed to delete lock file: \(error.localizedDescription)")
1239+
reject("delete_error", "Failed to delete lock file", error)
1240+
}
1241+
}
1242+
12231243
func shutdownInternal() {
12241244
NSLog("ReactNative shutdownInternal")
12251245
if self.fula != nil {

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.30",
3+
"version": "1.54.31",
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",

src/interfaces/fulaNativeModule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ interface FulaNativeModule {
145145
getInstallOutput: (pluginName: string, params: string) => Promise<string>;
146146
getInstallStatus: (pluginName: string) => Promise<string>;
147147
updatePlugin: (pluginName: string) => Promise<string>;
148+
deleteDsLock: () => Promise<void>;
148149
}
149150

150151
const LINKING_ERROR =

src/protocols/fula.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ export const isReady = (filesystemCheck: boolean = true): Promise<boolean> => {
348348
return Fula.isReady(filesystemCheck);
349349
};
350350

351+
export const deleteDsLock = (): Promise<void> => {
352+
return Fula.deleteDsLock();
353+
}
354+
351355
/**
352356
* replicate replicates data on the nework
353357
*/

0 commit comments

Comments
 (0)