mirror of
https://github.com/stashapp/stash.git
synced 2025-12-10 10:22:18 +01:00
Rather than passing a pointer to a waitgroup into task.Start(..) functions, handle the waitgroup.Done() at the callsite. This makes waitgroup handling local to its definition rather than it being spread out over multiple files. Tasks now simply execute, and the policy of waiting on them is handled by the caller.
32 lines
695 B
Go
32 lines
695 B
Go
package manager
|
|
|
|
import (
|
|
"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() {
|
|
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
|
|
}
|
|
|
|
MigrateHash(oldHash, newHash)
|
|
}
|