feat(taildrop): fix DirectFileMode, void callbacks, and empty WaitingFiles
- Add SetStagedFileOps to Extension: sets fileOps without enabling DirectFileMode, so WASM clients use staged retrieval (WaitingFiles, OpenFile, DeleteFile) instead of direct-write mode. - Add directFileOps bool field: SetFileOps (Android SAF) sets it true; SetStagedFileOps (WASM JS) leaves it false. onChangeProfile now uses `fops != nil && e.directFileOps` to determine DirectFileMode. - Add jsCallVoid to jsFileOps: void ops (openWriter, write, closeWriter, remove) now use cb(err?: string) instead of cb(null, err: string). - Fix waitingFiles() returning JSON null when no files are waiting: normalise nil slice to empty slice before marshalling. - Update wireTaildropFileOps to call SetStagedFileOps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,7 @@ func newIPN(jsConfig js.Value) map[string]any {
|
||||
if err := ns.Start(lb); err != nil {
|
||||
log.Fatalf("failed to start netstack: %v", err)
|
||||
}
|
||||
wireTaildropFileOps(lb, jsConfig.Get("fileOps"))
|
||||
srv.SetLocalBackend(lb)
|
||||
|
||||
jsIPN := &jsIPN{
|
||||
@@ -267,6 +268,33 @@ func newIPN(jsConfig js.Value) map[string]any {
|
||||
}
|
||||
return jsIPN.setExitNodeEnabled(args[0].Bool())
|
||||
}),
|
||||
"listFileTargets": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
return jsIPN.listFileTargets()
|
||||
}),
|
||||
"sendFile": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
if len(args) != 3 {
|
||||
log.Printf("Usage: sendFile(stableNodeID, filename, data)")
|
||||
return nil
|
||||
}
|
||||
return jsIPN.sendFile(args[0].String(), args[1].String(), args[2])
|
||||
}),
|
||||
"waitingFiles": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
return jsIPN.waitingFiles()
|
||||
}),
|
||||
"openWaitingFile": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
if len(args) != 1 {
|
||||
log.Printf("Usage: openWaitingFile(name)")
|
||||
return nil
|
||||
}
|
||||
return jsIPN.openWaitingFile(args[0].String())
|
||||
}),
|
||||
"deleteWaitingFile": js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
if len(args) != 1 {
|
||||
log.Printf("Usage: deleteWaitingFile(name)")
|
||||
return nil
|
||||
}
|
||||
return jsIPN.deleteWaitingFile(args[0].String())
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user