mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-28 11:16:37 +08:00
b0fe40142a
* Rebrand MMTL to MeBox across codebase and assets Rename the project display name, Go module path, environment variable prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl to MeBox/mebox. Replace logo assets with the new MeBox icon and keep legacy SQLite migration support for existing mmtl.db deployments. Co-authored-by: truewhile <truewhile@users.noreply.github.com> * Fix logo icons: use cube-only crop without truncated text Previous icon generation cropped too much of the source image, including partial MeBox wordmark text that was cut off in square icon containers. Regenerate logo-64/192/512, favicon, and SVG from cube-only region. Co-authored-by: truewhile <truewhile@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package service
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/fsnotify/fsnotify"
|
|
"go.uber.org/zap"
|
|
|
|
"github.com/truewhile/MeBox/internal/model"
|
|
"github.com/truewhile/MeBox/internal/repository"
|
|
)
|
|
|
|
func TestWatcherRefreshMapsHostLibraryPathToContainerPath(t *testing.T) {
|
|
root := t.TempDir()
|
|
hostMedia := filepath.Join(root, "nas-host", "media")
|
|
containerMedia := filepath.Join(root, "container", "media")
|
|
containerLibrary := filepath.Join(containerMedia, "电视剧", "国产剧")
|
|
if err := os.MkdirAll(containerLibrary, 0o755); err != nil {
|
|
t.Fatalf("mkdir container library: %v", err)
|
|
}
|
|
t.Setenv("MEBOX_MEDIA_DIR", hostMedia)
|
|
t.Setenv("MEBOX_MEDIA_CONTAINER_DIR", containerMedia)
|
|
|
|
db := newServiceTestDB(t, &model.Library{})
|
|
repos := repository.New(db)
|
|
lib := model.Library{
|
|
Base: model.Base{ID: "lib-tv"},
|
|
Name: "国产剧",
|
|
Path: filepath.Join(hostMedia, "电视剧", "国产剧"),
|
|
Type: "tv",
|
|
Enabled: true,
|
|
}
|
|
if err := repos.Library.Create(t.Context(), &lib); err != nil {
|
|
t.Fatalf("create library: %v", err)
|
|
}
|
|
fw, err := fsnotify.NewWatcher()
|
|
if err != nil {
|
|
t.Fatalf("new watcher: %v", err)
|
|
}
|
|
defer fw.Close()
|
|
watcher := NewWatcherService(zap.NewNop(), repos, nil)
|
|
watcher.watcher = fw
|
|
|
|
if err := watcher.Refresh(t.Context()); err != nil {
|
|
t.Fatalf("refresh: %v", err)
|
|
}
|
|
if _, ok := watcher.watched[filepath.Clean(containerLibrary)]; !ok {
|
|
t.Fatalf("expected mapped container path watched, got %#v", watcher.watched)
|
|
}
|
|
if _, ok := watcher.watched[filepath.Clean(lib.Path)]; ok {
|
|
t.Fatalf("host path should not be watched inside container: %#v", watcher.watched)
|
|
}
|
|
}
|