mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 21:49:15 +00:00
* Use libmagic to identify file types. * Fix mime array for database querying. * go mod tidy * Fix typo * Another fix for the scheduled image build workflow for tag case (#1137) * Try to fix the incorrect tag processing * more debug code * try with context=git * hopefully, final debug * the final commit with no debug code --------- Co-authored-by: Konstantin Koval * Add benchmark. * rollback workflows. * Fix AI comments. * Build image. * Fix AI comments. * Fix AI comments. * Rollback build workflow. --------- Co-authored-by: Kostiantyn <32730812+kkovaletp@users.noreply.github.com>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package processing_tasks
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
|
|
"github.com/photoview/photoview/api/scanner/media_encoding"
|
|
"github.com/photoview/photoview/api/scanner/media_type"
|
|
"github.com/photoview/photoview/api/scanner/scanner_task"
|
|
"github.com/photoview/photoview/api/utils"
|
|
)
|
|
|
|
type CounterpartFilesTask struct {
|
|
scanner_task.ScannerTaskBase
|
|
}
|
|
|
|
func (t CounterpartFilesTask) MediaFound(ctx scanner_task.TaskContext, fileInfo fs.FileInfo, mediaPath string) (skip bool, err error) {
|
|
fileType := media_type.GetMediaType(mediaPath)
|
|
|
|
if !fileType.IsSupported() {
|
|
return true, nil
|
|
}
|
|
|
|
if utils.EnvDisableRawProcessing.GetBool() {
|
|
if !fileType.IsWebCompatible() {
|
|
return true, nil
|
|
}
|
|
|
|
// Don't skip the JPEGs if raw processing is disabled. Treat them as standalone files.
|
|
return false, nil
|
|
}
|
|
|
|
if fileType.IsWebCompatible() {
|
|
_, existed := media_type.FindRawCounterpart(mediaPath)
|
|
if existed {
|
|
return true, nil
|
|
}
|
|
}
|
|
|
|
return false, nil
|
|
}
|
|
|
|
func (t CounterpartFilesTask) BeforeProcessMedia(ctx scanner_task.TaskContext, mediaData *media_encoding.EncodeMediaData) (scanner_task.TaskContext, error) {
|
|
|
|
mediaType, err := ctx.GetCache().GetMediaType(mediaData.Media.Path)
|
|
if err != nil {
|
|
return ctx, fmt.Errorf("scan for counterpart file error: %w", err)
|
|
}
|
|
|
|
if mediaType.IsWebCompatible() {
|
|
return ctx, nil
|
|
}
|
|
|
|
counterpartFile, ok := media_type.FindWebCounterpart(mediaData.Media.Path)
|
|
if !ok {
|
|
return ctx, nil
|
|
}
|
|
|
|
mediaData.CounterpartPath = &counterpartFile
|
|
|
|
return ctx, nil
|
|
}
|