Skip to content

Commit 012332d

Browse files
committed
Store relative paths for the actual files to send file scans to Emby &
Jellyfin Signed-off-by: Anagh Kumar Baranwal <[email protected]>
1 parent 7982fe1 commit 012332d

File tree

21 files changed

+342
-217
lines changed

21 files changed

+342
-217
lines changed

.github/workflows/build.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
steps:
1717
# dependencies
1818
- name: goreleaser
19-
uses: goreleaser/goreleaser-action@v3
19+
uses: goreleaser/goreleaser-action@v4
2020
with:
2121
install-only: true
22-
version: 1.7.0
22+
version: latest
2323

2424
- name: goreleaser info
2525
run: goreleaser -v
@@ -44,9 +44,9 @@ jobs:
4444

4545
# setup go
4646
- name: go
47-
uses: actions/setup-go@v3
47+
uses: actions/setup-go@v4
4848
with:
49-
go-version: 1.19
49+
go-version: 1.21
5050

5151
- name: go info
5252
run: |
@@ -106,15 +106,9 @@ jobs:
106106
name: build_linux
107107
path: dist/*linux*
108108

109-
- name: artifact_darwin
110-
uses: actions/upload-artifact@v3
111-
with:
112-
name: build_darwin
113-
path: dist/*darwin*
114-
115109
# docker login
116110
- name: docker login
117-
uses: docker/login-action@v1
111+
uses: docker/login-action@v2
118112
with:
119113
registry: ghcr.io
120114
username: ${{ github.repository_owner }}

.goreleaser.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ builds:
1111
main: ./cmd/autoscan
1212
goarch:
1313
- amd64
14+
goamd64:
15+
- v2
1416
ldflags:
1517
- -s -w
1618
- -X "main.Version={{ .Version }}"
1719
- -X "main.GitCommit={{ .ShortCommit }}"
1820
- -X "main.Timestamp={{ .Timestamp }}"
1921
flags:
2022
- -trimpath
21-
ignore:
22-
- goos: freebsd
23-
goarch: arm64
24-
- goos: freebsd
25-
goarch: arm
2623

2724
# MacOS Universal Binaries
2825
universal_binaries:

Taskfile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ tasks:
5353
release:
5454
desc: Generate a release, but don't publish
5555
cmds:
56-
- goreleaser --skip-validate --skip-publish --rm-dist
56+
- goreleaser --skip-validate --skip-publish --clean
5757

5858
snapshot:
5959
desc: Generate a snapshot release
6060
cmds:
61-
- goreleaser --snapshot --skip-publish --rm-dist
61+
- goreleaser --snapshot --skip-publish --clean
6262

6363
publish:
6464
desc: Generate a release, and publish
6565
cmds:
66-
- goreleaser --rm-dist
66+
- goreleaser --clean

autoscan.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import (
1313
//
1414
// The Scan is used across Triggers, Targets and the Processor.
1515
type Scan struct {
16-
Folder string
17-
Priority int
18-
Time time.Time
16+
Folder string
17+
RelativePath string
18+
Priority int
19+
Time time.Time
1920
}
2021

2122
type ProcessorFunc func(...Scan) error

cmd/autoscan/main.go

+13-34
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ func main() {
168168
Err(err).
169169
Msg("Failed opening config")
170170
}
171-
defer file.Close()
171+
defer func() {
172+
_ = file.Close()
173+
}()
172174

173175
// set default values
174176
c := config{
@@ -353,10 +355,9 @@ func main() {
353355
targetsAvailable := false
354356
targetsSize := len(targets)
355357
for {
356-
// sleep indefinitely when no targets setup
358+
// exit when no targets setup
357359
if targetsSize == 0 {
358-
log.Warn().Msg("No targets initialised, processor stopped, triggers will continue...")
359-
select {}
360+
log.Fatal().Msg("No targets initialised, exiting...")
360361
}
361362

362363
// target availability checker
@@ -365,18 +366,12 @@ func main() {
365366
switch {
366367
case err == nil:
367368
targetsAvailable = true
369+
368370
case errors.Is(err, autoscan.ErrFatal):
369-
log.Error().
370-
Err(err).
371-
Msg("Fatal error occurred while checking target availability, processor stopped, triggers will continue...")
371+
log.Fatal().Err(err).Msg("Fatal error occurred while checking target availability, exiting...")
372372

373-
// sleep indefinitely
374-
select {}
375373
default:
376-
log.Error().
377-
Err(err).
378-
Msg("Not all targets are available, retrying in 15 seconds...")
379-
374+
log.Error().Err(err).Msg("Not all targets are available, retrying in 15 seconds...")
380375
time.Sleep(15 * time.Second)
381376
continue
382377
}
@@ -391,40 +386,24 @@ func main() {
391386

392387
case errors.Is(err, autoscan.ErrNoScans):
393388
// No scans currently available, let's wait a couple of seconds
394-
log.Trace().
395-
Msg("No scans are available, retrying in 15 seconds...")
396-
389+
log.Trace().Msg("No scans are available, retrying in 15 seconds...")
397390
time.Sleep(15 * time.Second)
398391

399392
case errors.Is(err, autoscan.ErrAnchorUnavailable):
400-
log.Error().
401-
Err(err).
402-
Msg("Not all anchor files are available, retrying in 15 seconds...")
403-
393+
log.Error().Err(err).Msg("Not all anchor files are available, retrying in 15 seconds...")
404394
time.Sleep(15 * time.Second)
405395

406396
case errors.Is(err, autoscan.ErrTargetUnavailable):
407397
targetsAvailable = false
408-
log.Error().
409-
Err(err).
410-
Msg("Not all targets are available, retrying in 15 seconds...")
411-
398+
log.Error().Err(err).Msg("Not all targets are available, retrying in 15 seconds...")
412399
time.Sleep(15 * time.Second)
413400

414401
case errors.Is(err, autoscan.ErrFatal):
415-
// fatal error occurred, processor must stop (however, triggers must not)
416-
log.Error().
417-
Err(err).
418-
Msg("Fatal error occurred while processing targets, processor stopped, triggers will continue...")
419-
420-
// sleep indefinitely
421-
select {}
402+
log.Error().Err(err).Msg("Fatal error occurred while processing targets, exiting...")
422403

423404
default:
424405
// unexpected error
425-
log.Fatal().
426-
Err(err).
427-
Msg("Failed processing targets")
406+
log.Fatal().Err(err).Msg("Failed processing targets, exiting...")
428407
}
429408
}
430409
}

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENV \
1212
AUTOSCAN_VERBOSITY="0"
1313

1414
# Binary
15-
COPY ["./dist/autoscan_${TARGETOS}_${TARGETARCH}${TARGETVARIANT:+_7}/autoscan", "/app/autoscan/autoscan"]
15+
COPY ["./dist/autoscan_${TARGETOS}_${TARGETARCH}${TARGETVARIANT:+_7}_v2/autoscan", "/app/autoscan/autoscan"]
1616

1717
# Add root files
1818
COPY ["./docker/run", "/etc/services.d/autoscan/run"]

go.mod

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
module github.com/cloudbox/autoscan
22

3-
go 1.19
3+
go 1.21
44

55
require (
6-
github.com/BurntSushi/toml v0.3.1 // indirect
7-
github.com/alecthomas/kong v0.6.1
8-
github.com/fsnotify/fsnotify v1.5.4
9-
github.com/go-chi/chi/v5 v5.0.7
6+
github.com/alecthomas/kong v0.8.0
7+
github.com/fsnotify/fsnotify v1.6.0
8+
github.com/go-chi/chi/v5 v5.0.10
109
github.com/l3uddz/bernard v0.5.1
1110
github.com/m-rots/stubbs v1.1.0
12-
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
1311
github.com/natefinch/lumberjack v2.0.0+incompatible
14-
github.com/oriser/regroup v0.0.0-20210730155327-fca8d7531263
12+
github.com/oriser/regroup v0.0.0-20201024192559-010c434ff8f3
1513
github.com/robfig/cron/v3 v3.0.1
16-
github.com/rs/zerolog v1.28.0
17-
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
18-
golang.org/x/sync v0.0.0-20220907140024-f12130a52804
19-
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
20-
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
21-
golang.org/x/tools v0.1.12 // indirect
22-
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
14+
github.com/rs/zerolog v1.30.0
15+
golang.org/x/sync v0.3.0
16+
golang.org/x/time v0.3.0
2317
gopkg.in/yaml.v2 v2.4.0
24-
modernc.org/cc/v3 v3.38.1 // indirect
25-
modernc.org/sqlite v1.18.2
26-
modernc.org/strutil v1.1.3 // indirect
18+
modernc.org/sqlite v1.25.0
2719
)
2820

2921
require (
22+
github.com/BurntSushi/toml v1.3.2 // indirect
23+
github.com/dustin/go-humanize v1.0.1 // indirect
3024
github.com/google/uuid v1.3.0 // indirect
3125
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
3226
github.com/mattn/go-colorable v0.1.13 // indirect
33-
github.com/mattn/go-isatty v0.0.16 // indirect
34-
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
35-
github.com/rs/xid v1.4.0 // indirect
36-
lukechampine.com/uint128 v1.2.0 // indirect
37-
modernc.org/ccgo/v3 v3.16.9 // indirect
38-
modernc.org/libc v1.19.0 // indirect
39-
modernc.org/mathutil v1.5.0 // indirect
40-
modernc.org/memory v1.4.0 // indirect
27+
github.com/mattn/go-isatty v0.0.19 // indirect
28+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
29+
github.com/rs/xid v1.5.0 // indirect
30+
golang.org/x/mod v0.11.0 // indirect
31+
golang.org/x/sys v0.8.0 // indirect
32+
golang.org/x/tools v0.9.3 // indirect
33+
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
34+
lukechampine.com/uint128 v1.3.0 // indirect
35+
modernc.org/cc/v3 v3.41.0 // indirect
36+
modernc.org/ccgo/v3 v3.16.15 // indirect
37+
modernc.org/libc v1.24.1 // indirect
38+
modernc.org/mathutil v1.6.0 // indirect
39+
modernc.org/memory v1.7.0 // indirect
4140
modernc.org/opt v0.1.3 // indirect
42-
modernc.org/token v1.0.1 // indirect
41+
modernc.org/strutil v1.1.3 // indirect
42+
modernc.org/token v1.1.0 // indirect
4343
)

0 commit comments

Comments
 (0)