fix: token reload
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user