Fix CI and main app location
This commit is contained in:
parent
532a31ffdf
commit
63a5cf0052
6
.github/workflows/go.yml
vendored
6
.github/workflows/go.yml
vendored
@ -14,9 +14,9 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21
|
go-version: 1.22
|
||||||
- name: go vet -v ./...
|
- name: go vet ./...
|
||||||
run: go vet -v ./...
|
run: go vet ./...
|
||||||
- name: go test -v ./...
|
- name: go test -v ./...
|
||||||
run: go test -v ./...
|
run: go test -v ./...
|
||||||
- name: go build -v ./...
|
- name: go build -v ./...
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
keepr
|
|
||||||
assets/
|
assets/
|
||||||
|
BIN
cmd/keepr/keepr
Executable file
BIN
cmd/keepr/keepr
Executable file
Binary file not shown.
103
cmd/keepr/main.go
Normal file
103
cmd/keepr/main.go
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"kr.dev/walk"
|
||||||
|
|
||||||
|
"git.tcp.direct/kayos/keepr/internal/collect"
|
||||||
|
"git.tcp.direct/kayos/keepr/internal/config"
|
||||||
|
"git.tcp.direct/kayos/keepr/internal/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
log *zerolog.Logger
|
||||||
|
basepath = "/"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// TODO: fix this garbage
|
||||||
|
basepath = "C:\\"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
config.KeeprInit()
|
||||||
|
log = config.GetLogger()
|
||||||
|
var lastpath = ""
|
||||||
|
target := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(config.Source), "/"), "/")
|
||||||
|
cripwalk := walk.New(os.DirFS(basepath), target)
|
||||||
|
_, output := filepath.Split(strings.TrimSuffix(config.Output, "/"))
|
||||||
|
log.Trace().Msgf("output is %s", output)
|
||||||
|
for cripwalk.Next() {
|
||||||
|
if err := cripwalk.Err(); err != nil {
|
||||||
|
log.Fatal().Caller().Str("caller", lastpath).Msg(err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lastpath = cripwalk.Path()
|
||||||
|
slog := log.With().Str("caller", cripwalk.Path()).Logger()
|
||||||
|
switch {
|
||||||
|
case cripwalk.Entry() == nil:
|
||||||
|
slog.Trace().Msg("nil")
|
||||||
|
continue
|
||||||
|
case cripwalk.Entry().IsDir():
|
||||||
|
if strings.Contains(cripwalk.Path(), output) {
|
||||||
|
slog.Info().Msg("skiping directory entirely")
|
||||||
|
cripwalk.SkipDir()
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
// slog.Trace().Msg("directory")
|
||||||
|
default:
|
||||||
|
if strings.Contains(cripwalk.Path(), config.Output) {
|
||||||
|
log.Trace().Msg("skipping file in destination")
|
||||||
|
cripwalk.SkipDir()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
sample, err := collect.Process(cripwalk.Entry(), util.APath(cripwalk.Path(), config.Relative))
|
||||||
|
if err != nil {
|
||||||
|
slog.Warn().Caller().Str("caller", cripwalk.Path()).Err(err).Msgf("failed to process")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if sample == nil {
|
||||||
|
slog.Trace().Msgf("skipping unknown file")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
slog.Info().Interface("sample", sample).Msg("processed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.StatsOnly {
|
||||||
|
log.Info().Msg("Printing stats")
|
||||||
|
collect.Library.TempoStats()
|
||||||
|
collect.Library.KeyStats()
|
||||||
|
collect.Library.DrumStats()
|
||||||
|
collect.Library.TypeStats()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var errs []error
|
||||||
|
errs = append(errs, collect.Library.SymlinkTempos())
|
||||||
|
errs = append(errs, collect.Library.SymlinkKeys())
|
||||||
|
errs = append(errs, collect.Library.SymlinkDrums())
|
||||||
|
errs = append(errs, collect.Library.SymlinkMelodicLoops())
|
||||||
|
errs = append(errs, collect.Library.SymlinkMIDIs())
|
||||||
|
errs = append(errs, collect.Library.SymlinkArtists())
|
||||||
|
errs = append(errs, collect.Library.SymlinkGenres())
|
||||||
|
errs = append(errs, collect.Library.SymlinkSources())
|
||||||
|
errs = append(errs, collect.Library.SymlinkCreationDates())
|
||||||
|
errs = append(errs, collect.Library.SymlinkSoftwares())
|
||||||
|
|
||||||
|
for !atomic.CompareAndSwapInt32(&collect.Backlog, 0, -1) {
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
print(".")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info().Errs("errs", errs).Msg("fin.")
|
||||||
|
}
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module git.tcp.direct/kayos/keepr
|
module git.tcp.direct/kayos/keepr
|
||||||
|
|
||||||
go 1.22
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.tcp.direct/kayos/common v0.9.7
|
git.tcp.direct/kayos/common v0.9.7
|
||||||
|
Loading…
Reference in New Issue
Block a user