stash/internal/manager/task_migrate_hash.go
WithoutPants 273cf0383d [Files Refactor] Performance tuning (#2865)
* Don't load image files by default
* Don't load gallery files by default
* Don't load scene files by default
* Retry locked transactions forever
* Don't show release notes if config not loaded
* Don't translate path slashes in export
2022-09-06 07:04:52 +00:00

33 lines
740 B
Go

package manager
import (
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/scene"
)
// MigrateHashTask renames generated files between oshash and MD5 based on the
// value of the fileNamingAlgorithm flag.
type MigrateHashTask struct {
Scene *models.Scene
fileNamingAlgorithm models.HashAlgorithm
}
// Start starts the task.
func (t *MigrateHashTask) Start() {
if t.Scene.OSHash == "" || t.Scene.Checksum == "" {
// nothing to do
return
}
oshash := t.Scene.OSHash
checksum := t.Scene.Checksum
oldHash := oshash
newHash := checksum
if t.fileNamingAlgorithm == models.HashAlgorithmOshash {
oldHash = checksum
newHash = oshash
}
scene.MigrateHash(instance.Paths, oldHash, newHash)
}