preserve media store across config reloads
## Bug Fix Prevents loss of uploaded file references when using `/reload` command. ## Problem When calling `/reload`, a new `FileMediaStore` was created with an empty `refs` map, causing all previously uploaded files to become inaccessible with error: media store: unknown ref: media://... ## Solution Reuse the existing `MediaStore` instance instead of recreating it on every reload. The media store is now only created once on initial startup. ## Changes - `pkg/gateway/gateway.go` (line 468): Wrap media store creation in `if runningServices.MediaStore == nil` ## Testing 1. Start picoclaw with Telegram enabled 2. Upload a file to the bot 3. Run `/reload` command 4. Ask bot to read the previously uploaded file 5. File should now be accessible (previously would fail with "unknown ref" error) ## Impact - Users can now safely use `/reload` without breaking file uploads - No breaking changes - Backward compatible
This commit is contained in:
parent
9d6a445bb1
commit
3c2ecb2eda
1 changed files with 11 additions and 8 deletions
|
|
@ -480,6 +480,8 @@ func restartServices(
|
|||
}
|
||||
fmt.Println(" ✓ Heartbeat service restarted")
|
||||
|
||||
|
||||
if runningServices.MediaStore == nil {
|
||||
runningServices.MediaStore = media.NewFileMediaStoreWithCleanup(media.MediaCleanerConfig{
|
||||
Enabled: cfg.Tools.MediaCleanup.Enabled,
|
||||
MaxAge: time.Duration(cfg.Tools.MediaCleanup.MaxAge) * time.Minute,
|
||||
|
|
@ -487,6 +489,7 @@ func restartServices(
|
|||
})
|
||||
if fms, ok := runningServices.MediaStore.(*media.FileMediaStore); ok {
|
||||
fms.Start()
|
||||
}
|
||||
}
|
||||
al.SetMediaStore(runningServices.MediaStore)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue