fix: token reload

This commit is contained in:
Rogee
2024-12-15 01:19:03 +08:00
parent ed3d8b0e6c
commit 4a606bd824
9 changed files with 62 additions and 23 deletions

View File

@@ -95,12 +95,8 @@ func (d *DiscoverMedias) processVideo(video, to, hash string) (media_store.Video
return info, errors.Wrapf(err, "ensure directory: %s", to)
}
if err := d.ensureDirectory(filepath.Join(to, "posters")); err != nil {
return info, errors.Wrapf(err, "ensure directory: %s", to)
}
// extract poster
posterFile := filepath.Join(to, "posters", hash+".jpg")
posterFile := filepath.Join(to, hash+".jpg")
if err := d.ffmpegVideoToPoster(video, posterFile); err != nil {
return info, errors.Wrapf(err, "ffmpeg video to poster: %s", posterFile)
}
@@ -269,6 +265,10 @@ func (d *DiscoverMedias) runCleanup(to string) {
if err := os.RemoveAll(filepath.Join(to, dir)); err != nil {
d.log.Errorf("Remove dir: %s", dir)
}
if err := os.RemoveAll(filepath.Join(to, dir+".jpg")); err != nil {
d.log.Errorf("Remove poster: %s", dir+".jpg")
}
}
}

View File

@@ -2,6 +2,8 @@ package store
import (
"context"
"fmt"
"path/filepath"
"backend/modules/medias"
"backend/pkg/media_store"
@@ -25,13 +27,16 @@ func (d *StoreMedias) Prepare() error {
func (d *StoreMedias) RunE(targetPath string) error {
d.log.Infof("Store medias from: %s ", targetPath)
tenantId := int64(1)
targetPath = filepath.Join(targetPath, fmt.Sprintf("%d", tenantId))
store, err := media_store.NewStore(targetPath)
if err != nil {
return errors.Wrapf(err, "new store: %s", targetPath)
return errors.Wrapf(err, "store: %s", targetPath)
}
for _, item := range store {
err := d.mediasSvc.Upsert(context.Background(), 1, item)
err := d.mediasSvc.Upsert(context.Background(), tenantId, item)
if err != nil {
d.log.WithError(err).Errorf("upsert media: %s - %s", item.Hash, item.Name)
}