filed

Job queue using FUSE

git clone git://mccd.space/filed

commit d2f777f1bf1ecc7196d87f25a38268070cc0aa9c
parent 894ec948eb2f85d22ca554168e059d6d8258e9b5
Author: Marc Coquand <marc@coquand.email>
Date:   Thu, 18 Dec 2025 16:00:22 +0100

use filed-launch from PATH

Diffstat:
Mmain.go | 9++++++++-
Mmanager.go | 8+++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/main.go b/main.go
@@ -5,8 +5,10 @@ import (
 	"filed/store"
 	"flag"
 	"fmt"
+	"log"
 	"log/slog"
 	"os"
+	"os/exec"
 	"syscall"
 
 	"bazil.org/fuse"
@@ -27,6 +29,11 @@ func main() {
 		usage()
 		os.Exit(2)
 	}
+	filedLaunchExecutable, err := exec.LookPath("filed-launch")
+	if err != nil {
+		log.Fatalf("filed-launch needs to be available in $PATH: %v", err)
+	}
+
 	dbPath := os.Getenv("FILED_STATE_FILE")
 	if dbPath == "" {
 		xdg_home := os.Getenv("XDG_DATA_HOME")
@@ -67,7 +74,7 @@ func main() {
 	}
 	defer c.Close()
 
-	jobManager := NewJobManager(store)
+	jobManager := NewJobManager(store, filedLaunchExecutable)
 	ctx, cancel := context.WithCancel(context.Background())
 	defer cancel()
 	jobManager.StartWorker(ctx)
diff --git a/manager.go b/manager.go
@@ -17,6 +17,8 @@ import (
 type JobManager struct {
 	store      *store.Store
 	activeJobs sync.Map
+	// Command to use for executing jobs in pending
+	execCmd string
 }
 
 type ActiveJob struct {
@@ -25,9 +27,9 @@ type ActiveJob struct {
 	output bytes.Buffer
 }
 
-func NewJobManager(s *store.Store) *JobManager {
+func NewJobManager(s *store.Store, filedLaunchExecutablePath string) *JobManager {
 
-	return &JobManager{store: s}
+	return &JobManager{store: s, execCmd: filedLaunchExecutablePath}
 }
 
 func (jm *JobManager) StartWorker(ctx context.Context) {
@@ -116,7 +118,7 @@ func (jm *JobManager) runJob(id, commandStr string) {
 
 	args := strings.Fields(commandStr)
 
-	cmd := exec.CommandContext(ctx, "filed-launch", "--")
+	cmd := exec.CommandContext(ctx, jm.execCmd, "--")
 	cmd.Args = append(cmd.Args, args...)
 
 	writer := &SafeBuffer{target: active}