Skip to content

Commit f6218d0

Browse files
committed
feat: complete safe metadata editor, batch UI and anti-piracy rewrite
Replace the MP3-only ID3 path with a TagLib-backed metadata service for MP3, FLAC, WAV and AIFF. Service layer: - tri-state patches, per-format capabilities, picture validation - copy-on-write transaction with full-file snapshot, payload hash check and per-path locking so concurrent writes cannot clobber one file - bounded thumbnails for the WebView, public error sanitisation - batch preview/run/start/result/cancel with progress publication and descriptor-only picture preflight Anti-piracy: - V1 clears and V2 deranges every canonical text field, filtered per container capability so mixed formats do not fail wholesale - all eligible files are snapshotted before the first destructive write - restore reports blocked entries instead of silent success Frontend: - single/batch editor with dirty guards, picture editing and undo - batch composable with polling, cancel and per-file results - i18n labels for the new surfaces CI: - build pinned TagLib and run ctest plus native DLL Go tests - add a Windows release job that produces the Wails binary, helper, native DLLs and the NSIS installer, then uploads them as artifacts
1 parent 05a75ee commit f6218d0

56 files changed

Lines changed: 8206 additions & 717 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test.yml‎

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ jobs:
6666
git diff --exit-code -- frontend/wailsjs || (
6767
echo "::error::bindings drifted; run wails generate module" && exit 1)
6868
69-
- name: Installer build and smoke assertions
69+
# The real installer is produced by the windows-release job, which builds
70+
# the native DLLs first. This job only asserts the packaging contract.
71+
- name: Installer contract assertions
7072
shell: bash
7173
run: |
72-
choco install nsis -y --no-progress >/dev/null
73-
makensis build/windows/installer/project.nsi
74-
ls build/bin/*installer*.exe
75-
# main EXE must be present, helper packaged next to it
7674
grep -q 'EngineTools.Helper.exe' build/windows/installer/project.nsi
75+
grep -q 'enginetools_tag.dll' build/windows/installer/project.nsi
76+
grep -q 'tag.dll' build/windows/installer/project.nsi
7777
! grep -q 'requireAdministrator' build/windows/wails.exe.manifest
7878
7979
id3-preservation:
@@ -95,7 +95,18 @@ jobs:
9595
- name: Install ffmpeg
9696
run: choco install ffmpeg -y --no-progress
9797

98+
- name: Build pinned TagLib and native bridge
99+
shell: pwsh
100+
run: ./build/windows/build-taglib.ps1
101+
102+
- name: Native bridge contract test
103+
shell: pwsh
104+
run: ctest --test-dir build/taglib/bridge-build -C Release --output-on-failure
105+
98106
- name: Go tests (metadata + snapshot + transaction)
107+
shell: pwsh
108+
env:
109+
ET_TAGLIB_DLL: ${{ github.workspace }}\build\bin\enginetools_tag.dll
99110
run: go test -race ./internal/metadata ./internal/snapshot -v
100111

101112
- name: Frontend unit tests
@@ -110,3 +121,80 @@ jobs:
110121
if grep -rnE 'MIDI2|midi2|Midi2\.|internal/midi' app.go internal frontend/src; then
111122
echo '::error::MIDI 2.0 references reappeared'; exit 1
112123
fi
124+
125+
windows-release:
126+
name: Windows release artifact
127+
runs-on: windows-latest
128+
defaults:
129+
run:
130+
shell: pwsh
131+
steps:
132+
- uses: actions/checkout@v5
133+
134+
- uses: actions/setup-go@v6
135+
with:
136+
go-version: "1.26"
137+
138+
- uses: actions/setup-node@v4
139+
with:
140+
node-version: "22"
141+
cache: npm
142+
cache-dependency-path: frontend/package-lock.json
143+
144+
- name: Install frontend dependencies
145+
run: npm --prefix frontend ci
146+
147+
# Native runtime first: build/bin is the output directory wails build
148+
# writes into, so never pass -clean after this point.
149+
- name: Build pinned TagLib and native bridge
150+
run: ./build/windows/build-taglib.ps1
151+
152+
- name: Build elevated helper
153+
run: ./build/windows/build-helper.ps1
154+
155+
- name: Install NSIS
156+
run: choco install nsis -y --no-progress
157+
158+
- name: Install Wails CLI
159+
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.12.0
160+
161+
- name: Regenerate Wails bindings for the artifact
162+
run: |
163+
$wails = Join-Path (go env GOPATH) 'bin\wails.exe'
164+
& $wails generate module
165+
if ($LASTEXITCODE -ne 0) { throw "wails generate failed with $LASTEXITCODE" }
166+
167+
- name: Wails release build with installer
168+
run: |
169+
$wails = Join-Path (go env GOPATH) 'bin\wails.exe'
170+
& $wails build -platform windows/amd64 -nsis -skipbindings
171+
if ($LASTEXITCODE -ne 0) { throw "wails build failed with $LASTEXITCODE" }
172+
173+
- name: Verify packaged binaries
174+
run: |
175+
$required = @(
176+
'build\bin\EngineTools.exe',
177+
'build\bin\EngineTools.Helper.exe',
178+
'build\bin\enginetools_tag.dll',
179+
'build\bin\tag.dll',
180+
'build\bin\EngineTools-amd64-installer.exe'
181+
)
182+
foreach ($path in $required) {
183+
if (-not (Test-Path $path)) { throw "missing release artifact: $path" }
184+
}
185+
Get-ChildItem 'build\bin' | Select-Object Name, Length
186+
187+
- name: Upload Windows artifacts
188+
uses: actions/upload-artifact@v4
189+
with:
190+
name: EngineTools-windows-amd64
191+
if-no-files-found: error
192+
path: |
193+
build/bin/EngineTools.exe
194+
build/bin/EngineTools.Helper.exe
195+
build/bin/enginetools_tag.dll
196+
build/bin/tag.dll
197+
build/bin/EngineTools-amd64-installer.exe
198+
frontend/wailsjs/go/main/App.js
199+
frontend/wailsjs/go/main/App.d.ts
200+
frontend/wailsjs/go/models.ts

‎app.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ type App struct {
4141
mu sync.Mutex
4242
libraryPath string
4343
}
44+
45+
// metadata is initialized lazily because the native TagLib bridge is an
46+
// optional runtime artifact during development. Keeping the runtime behind
47+
// a mutex also prevents concurrent Wails calls from creating multiple
48+
// snapshot stores.
49+
metadataMu sync.Mutex
50+
metadata *metadataRuntime
4451
}
4552

4653
type StatusInfo struct {

‎app_database.go‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package main
33
import (
44
"EngineTools/internal/database"
55
"EngineTools/internal/i18n"
6-
"EngineTools/internal/id3"
6+
"EngineTools/internal/metadata"
77
"EngineTools/internal/process"
8+
"context"
89
"fmt"
910
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
1011
"golang.org/x/sys/windows"
@@ -185,17 +186,17 @@ func (a *App) CompressCovers(playlistID int, maxKB int) map[string]interface{} {
185186
a.setProgress(float64(i) / float64(total))
186187
}
187188

188-
res, err := id3.CompressCover(t.Path, maxBytes)
189+
result, err := a.compressCover(t.Path, maxBytes)
189190
if err != nil {
190191
failed++
191192
errors = append(errors, fmt.Sprintf("%s: %v", filepath.Base(t.Path), err))
192193
continue
193194
}
194-
if res.Skipped {
195+
if !result.Changed {
195196
skipped++
196197
} else {
197198
compressed++
198-
savedBytes += res.OriginalSize - res.FinalSize
199+
savedBytes += result.OriginalSize - result.FinalSize
199200
}
200201
}
201202

@@ -326,13 +327,16 @@ func (a *App) SyncBPMKeyToTags() map[string]interface{} {
326327
a.setProgress(float64(i) / float64(total))
327328
}
328329

329-
bpmStr := ""
330-
if t.BPM > 0 {
331-
bpmStr = fmt.Sprintf("%.2f", t.BPM)
332-
}
333330
keyStr := t.KeyName // e.g. "Am", "C"
334331

335-
if err := id3.WriteBPMKey(t.Path, bpmStr, keyStr); err != nil {
332+
patch := metadata.Patch{}
333+
if t.BPM > 0 {
334+
patch.BPM = metadata.FieldPatch[float64]{Mode: metadata.Set, Value: t.BPM}
335+
}
336+
if keyStr != "" {
337+
patch.Key = metadata.FieldPatch[string]{Mode: metadata.Set, Value: keyStr}
338+
}
339+
if _, err := a.MetadataApply(t.Path, patch); err != nil {
336340
failed++
337341
errors = append(errors, fmt.Sprintf("%s: %v", filepath.Base(t.Path), err))
338342
} else {
@@ -355,6 +359,18 @@ func (a *App) SyncBPMKeyToTags() map[string]interface{} {
355359
}
356360
}
357361

362+
// compressCover delegates picture inspection and replacement to the same
363+
// transactional metadata service used by the editor. A descriptor-only native
364+
// bridge returns a structured skip rather than pretending that compression
365+
// succeeded.
366+
func (a *App) compressCover(path string, maxBytes int64) (metadata.PictureCompressionResult, error) {
367+
rt, err := a.metadataServices()
368+
if err != nil {
369+
return metadata.PictureCompressionResult{}, metadataUnavailable(err)
370+
}
371+
return rt.service.CompressFrontPicture(context.Background(), path, maxBytes)
372+
}
373+
358374
func checkIsAdmin() bool {
359375
var sid *windows.SID
360376
err := windows.AllocateAndInitializeSid(

0 commit comments

Comments
 (0)