diff --git a/internal/sync/extras.go b/internal/sync/extras.go index e962109a6..1fa65fa9b 100644 --- a/internal/sync/extras.go +++ b/internal/sync/extras.go @@ -19,9 +19,16 @@ type ExtraResult struct { Warnings []string // Non-fatal warnings (e.g. flatten collisions) } +// reservedMetadataFile is skillshare's per-directory install-tracking store +// (mirrors install.MetadataFileName, duplicated here to avoid an import cycle). +// It is internal bookkeeping, not user content, so it must never be synced or +// transformed into a target directory. +const reservedMetadataFile = ".metadata.json" + // DiscoverExtraFiles recursively walks sourcePath and returns relative paths -// of all regular files. Directories named ".git" are skipped. Results are -// sorted for deterministic output. +// of all regular files. Directories named ".git" and skillshare's reserved +// .metadata.json bookkeeping file are skipped. Results are sorted for +// deterministic output. func DiscoverExtraFiles(sourcePath string) ([]string, error) { info, err := os.Stat(sourcePath) if err != nil { @@ -45,6 +52,9 @@ func DiscoverExtraFiles(sourcePath string) ([]string, error) { } return nil } + if fi.Name() == reservedMetadataFile { + return nil // skillshare's internal tracking store, never sync it + } rel, relErr := filepath.Rel(sourcePath, path) if relErr != nil { return nil diff --git a/internal/sync/extras_test.go b/internal/sync/extras_test.go index 80a229f8b..01caeb941 100644 --- a/internal/sync/extras_test.go +++ b/internal/sync/extras_test.go @@ -56,6 +56,24 @@ func TestDiscoverExtraFiles(t *testing.T) { } } +// TestDiscoverExtraFiles_SkipsMetadata verifies skillshare's reserved +// .metadata.json tracking store is never discovered, so it cannot be synced or +// transformed into a target (e.g. installed-agent dirs carry one). +func TestDiscoverExtraFiles_SkipsMetadata(t *testing.T) { + src, _ := setupExtrasTest(t, map[string]string{ + "agent.md": "# Agent", + ".metadata.json": `{"version":1,"entries":{}}`, + }) + + files, err := DiscoverExtraFiles(src) + if err != nil { + t.Fatal(err) + } + if len(files) != 1 || files[0] != "agent.md" { + t.Errorf("expected only [agent.md], got %v", files) + } +} + // --- SyncExtra merge mode tests --- func TestSyncExtra_MergeMode(t *testing.T) {