Some checks failed
Release / build (push) Failing after 19s
Full Syncthing tray wrapper with: - System tray with 5 icon states (idle/syncing/paused/error/disconnected) - Syncthing REST API client with auto-discovered API key - Long-polling event listener for real-time status - Transfer rate monitoring, folder tracking, recent files, conflict counting - Full context menu with folders, recent files, settings toggles - Embedded admin panel binary (webview, requires CGO) - OS notifications via beeep (per-event configurable) - Syncthing process management with auto-restart - Cross-platform installer with autostart - CI pipeline for Linux (.deb + .tar.gz) and Windows (.zip) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
987 B
Go
50 lines
987 B
Go
package monitor
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
const maxRecentFiles = 10
|
|
|
|
// RecentTracker maintains a ring buffer of recently synced files.
|
|
type RecentTracker struct {
|
|
mu sync.Mutex
|
|
files []RecentFile
|
|
}
|
|
|
|
// NewRecentTracker creates a new recent files tracker.
|
|
func NewRecentTracker() *RecentTracker {
|
|
return &RecentTracker{
|
|
files: make([]RecentFile, 0, maxRecentFiles),
|
|
}
|
|
}
|
|
|
|
// Add records a newly synced file.
|
|
func (rt *RecentTracker) Add(name, folder string) {
|
|
rt.mu.Lock()
|
|
defer rt.mu.Unlock()
|
|
|
|
rf := RecentFile{
|
|
Name: name,
|
|
Folder: folder,
|
|
Timestamp: time.Now(),
|
|
}
|
|
|
|
// Prepend (most recent first)
|
|
rt.files = append([]RecentFile{rf}, rt.files...)
|
|
if len(rt.files) > maxRecentFiles {
|
|
rt.files = rt.files[:maxRecentFiles]
|
|
}
|
|
}
|
|
|
|
// Files returns a snapshot of recent files (most recent first).
|
|
func (rt *RecentTracker) Files() []RecentFile {
|
|
rt.mu.Lock()
|
|
defer rt.mu.Unlock()
|
|
|
|
out := make([]RecentFile, len(rt.files))
|
|
copy(out, rt.files)
|
|
return out
|
|
}
|