2020-08-06 01:21:14 +00:00
|
|
|
package manager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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(wg *sync.WaitGroup) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
if !t.Scene.OSHash.Valid || !t.Scene.Checksum.Valid {
|
|
|
|
// nothing to do
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
oshash := t.Scene.OSHash.String
|
|
|
|
checksum := t.Scene.Checksum.String
|
|
|
|
|
|
|
|
oldHash := oshash
|
|
|
|
newHash := checksum
|
|
|
|
if t.fileNamingAlgorithm == models.HashAlgorithmOshash {
|
|
|
|
oldHash = checksum
|
|
|
|
newHash = oshash
|
|
|
|
}
|
|
|
|
|
2021-02-09 23:50:34 +00:00
|
|
|
MigrateHash(oldHash, newHash)
|
2020-08-06 01:21:14 +00:00
|
|
|
}
|