From 16d818d03dfd25a25eafe511f4b4f2bddc3b121e Mon Sep 17 00:00:00 2001 From: mixeme Date: Thu, 18 Jun 2026 22:35:51 +0300 Subject: [PATCH] T1.6: Create src/platform/autostart; move autostart logic Move autostart_*.go and tests from src/core to src/platform/autostart. Update src/gui/app.go to call autostart.SetAutostart / autostart.AutostartStatus. Add quoteDesktopExec to desktop_linux.go (was co-located in autostart_linux.go). Co-Authored-By: Claude Sonnet 4.6 --- docs/REFACTORING.md | 2 +- src/core/desktop_linux.go | 5 +++++ src/gui/app.go | 5 +++-- src/{core => platform/autostart}/autostart_linux.go | 2 +- src/{core => platform/autostart}/autostart_linux_test.go | 2 +- src/{core => platform/autostart}/autostart_other.go | 2 +- src/{core => platform/autostart}/autostart_windows.go | 2 +- src/{core => platform/autostart}/autostart_windows_test.go | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) rename src/{core => platform/autostart}/autostart_linux.go (99%) rename src/{core => platform/autostart}/autostart_linux_test.go (98%) rename src/{core => platform/autostart}/autostart_other.go (96%) rename src/{core => platform/autostart}/autostart_windows.go (99%) rename src/{core => platform/autostart}/autostart_windows_test.go (99%) diff --git a/docs/REFACTORING.md b/docs/REFACTORING.md index ccd10ba..0d91c08 100644 --- a/docs/REFACTORING.md +++ b/docs/REFACTORING.md @@ -249,7 +249,7 @@ Track progress here. Mark tasks complete as they land and pass review. - [x] T1.3 — Create `src/runner`; move runner logic - [x] T1.4 — Create `src/scheduler`; move scheduler - [x] T1.5 — Create `src/storage`; move store/paths -- [ ] T1.6 — Create `src/platform/autostart`; move autostart logic +- [x] T1.6 — Create `src/platform/autostart`; move autostart logic - [ ] T1.7 — Create `src/platform/desktop`; move desktop integration - [ ] T1.8 — Delete empty `src/core`; build + test both platforms diff --git a/src/core/desktop_linux.go b/src/core/desktop_linux.go index c099bd4..4619e5f 100644 --- a/src/core/desktop_linux.go +++ b/src/core/desktop_linux.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" ) func InstallDesktopIntegration(appID string, executablePath string, icon []byte) (string, error) { @@ -40,6 +41,10 @@ StartupWMClass=%s return iconPath, nil } +func quoteDesktopExec(path string) string { + return strconv.Quote(path) +} + func xdgDataHome() (string, error) { dataHome := os.Getenv("XDG_DATA_HOME") if dataHome == "" { diff --git a/src/gui/app.go b/src/gui/app.go index 0764ef3..41b6cb3 100644 --- a/src/gui/app.go +++ b/src/gui/app.go @@ -15,6 +15,7 @@ import ( "gitea.mixdep.ru/mix/gosentry/assets" "gitea.mixdep.ru/mix/gosentry/src/core" "gitea.mixdep.ru/mix/gosentry/src/domain" + "gitea.mixdep.ru/mix/gosentry/src/platform/autostart" "gitea.mixdep.ru/mix/gosentry/src/runner" "gitea.mixdep.ru/mix/gosentry/src/scheduler" "gitea.mixdep.ru/mix/gosentry/src/storage" @@ -910,7 +911,7 @@ func settingsView(w fyne.Window, store *storage.Store, jobs *[]job) fyne.CanvasO startOnLogin.SetChecked(store.Config.StartOnLogin) autostartStatus := widget.NewLabel("") refreshAutostartStatus := func() { - ok, message := core.AutostartStatus(store.Config.StartOnLogin, store.Paths.ExecutablePath) + ok, message := autostart.AutostartStatus(store.Config.StartOnLogin, store.Paths.ExecutablePath) if ok { autostartStatus.SetText("OK: " + message) return @@ -975,7 +976,7 @@ func settingsView(w fyne.Window, store *storage.Store, jobs *[]job) fyne.CanvasO settingsStatus.SetText("Save failed: " + err.Error()) return } - if err := core.SetAutostart(store.Config.StartOnLogin, store.Paths.ExecutablePath, store.Paths.DesktopIcon); err != nil { + if err := autostart.SetAutostart(store.Config.StartOnLogin, store.Paths.ExecutablePath, store.Paths.DesktopIcon); err != nil { refreshAutostartStatus() settingsStatus.SetText("Saved, autostart failed: " + err.Error()) return diff --git a/src/core/autostart_linux.go b/src/platform/autostart/autostart_linux.go similarity index 99% rename from src/core/autostart_linux.go rename to src/platform/autostart/autostart_linux.go index 670a6d3..8ccb8c1 100644 --- a/src/core/autostart_linux.go +++ b/src/platform/autostart/autostart_linux.go @@ -1,6 +1,6 @@ //go:build linux -package core +package autostart import ( "fmt" diff --git a/src/core/autostart_linux_test.go b/src/platform/autostart/autostart_linux_test.go similarity index 98% rename from src/core/autostart_linux_test.go rename to src/platform/autostart/autostart_linux_test.go index 52f1a66..22ebc1f 100644 --- a/src/core/autostart_linux_test.go +++ b/src/platform/autostart/autostart_linux_test.go @@ -1,6 +1,6 @@ //go:build linux -package core +package autostart import ( "os" diff --git a/src/core/autostart_other.go b/src/platform/autostart/autostart_other.go similarity index 96% rename from src/core/autostart_other.go rename to src/platform/autostart/autostart_other.go index b9ac296..5eab3f7 100644 --- a/src/core/autostart_other.go +++ b/src/platform/autostart/autostart_other.go @@ -1,6 +1,6 @@ //go:build !windows && !linux -package core +package autostart import "fmt" diff --git a/src/core/autostart_windows.go b/src/platform/autostart/autostart_windows.go similarity index 99% rename from src/core/autostart_windows.go rename to src/platform/autostart/autostart_windows.go index 157a207..813ef21 100644 --- a/src/core/autostart_windows.go +++ b/src/platform/autostart/autostart_windows.go @@ -1,4 +1,4 @@ -package core +package autostart import ( "fmt" diff --git a/src/core/autostart_windows_test.go b/src/platform/autostart/autostart_windows_test.go similarity index 99% rename from src/core/autostart_windows_test.go rename to src/platform/autostart/autostart_windows_test.go index 827e22d..c0a0d66 100644 --- a/src/core/autostart_windows_test.go +++ b/src/platform/autostart/autostart_windows_test.go @@ -1,6 +1,6 @@ //go:build windows -package core +package autostart import ( "os"