fix(local-tool): flash 模型檔案找不到 — 相對路徑未解析
根因:models.json 的 filePath 是相對路徑("data/nef/kl520/xxx.nef"),
但 server working directory 是 {app}\bin\(app.go 設 cmd.Dir = binary 目錄),
所以 server 在 {app}\bin\data\nef\ 找 .nef 檔,找不到。
實際位置:{app}\data\nef\(installer 裝的位置),對應 server 的 --data-dir
由 Wails app 傳入的 %APPDATA%\visiona-local(或 fallback 到 <exe>/../data)。
修法:
- flash.NewService 新增 dataDir 參數
- StartFlash 中把相對 filePath 用 dataDir 拼接成絕對路徑:
"data/nef/..." → 去掉 "data/" 前綴 → dataDir + "/nef/..."
- main.go 傳 dataDir 給 flash.NewService
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c24a04cdb2
commit
aa324cef42
@ -66,13 +66,15 @@ func resolveModelPath(filePath string, deviceType string) string {
|
||||
type Service struct {
|
||||
deviceMgr *device.Manager
|
||||
modelRepo *model.Repository
|
||||
dataDir string
|
||||
tracker *ProgressTracker
|
||||
}
|
||||
|
||||
func NewService(deviceMgr *device.Manager, modelRepo *model.Repository) *Service {
|
||||
func NewService(deviceMgr *device.Manager, modelRepo *model.Repository, dataDir string) *Service {
|
||||
return &Service{
|
||||
deviceMgr: deviceMgr,
|
||||
modelRepo: modelRepo,
|
||||
dataDir: dataDir,
|
||||
tracker: NewProgressTracker(),
|
||||
}
|
||||
}
|
||||
@ -106,6 +108,18 @@ func (s *Service) StartFlash(deviceID, modelID string) (string, <-chan driver.Fl
|
||||
return "", nil, fmt.Errorf("model %s has no .nef file path", modelID)
|
||||
}
|
||||
|
||||
// models.json 的 filePath 是相對路徑(例如 "data/nef/kl520/xxx.nef")。
|
||||
// 如果不是絕對路徑,用 dataDir 解析:
|
||||
// "data/nef/..." → 去掉 "data/" 前綴 → dataDir + "/nef/..."
|
||||
// 其他相對路徑 → dataDir + "/" + filePath
|
||||
if !filepath.IsAbs(modelPath) {
|
||||
if strings.HasPrefix(modelPath, "data/") || strings.HasPrefix(modelPath, "data\\") {
|
||||
modelPath = filepath.Join(s.dataDir, modelPath[len("data/"):])
|
||||
} else {
|
||||
modelPath = filepath.Join(s.dataDir, modelPath)
|
||||
}
|
||||
}
|
||||
|
||||
modelPath = resolveModelPath(modelPath, deviceInfo.Type)
|
||||
|
||||
taskID := fmt.Sprintf("flash-%s-%s", deviceID, modelID)
|
||||
|
||||
@ -139,7 +139,7 @@ func main() {
|
||||
cameraMgr := camera.NewManager(cfg.MockCamera)
|
||||
|
||||
// Initialize services
|
||||
flashSvc := flash.NewService(deviceMgr, modelRepo)
|
||||
flashSvc := flash.NewService(deviceMgr, modelRepo, dataDir)
|
||||
inferenceSvc := inference.NewService(deviceMgr)
|
||||
|
||||
// Determine static file system for embedded frontend
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user