mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Rename marker folders when hash changes (#3988)
This commit is contained in:
@@ -16,14 +16,18 @@ func newSceneMarkerPaths(p Paths) *sceneMarkerPaths {
|
|||||||
return &sp
|
return &sp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sp *sceneMarkerPaths) GetFolderPath(checksum string) string {
|
||||||
|
return filepath.Join(sp.Markers, checksum)
|
||||||
|
}
|
||||||
|
|
||||||
func (sp *sceneMarkerPaths) GetVideoPreviewPath(checksum string, seconds int) string {
|
func (sp *sceneMarkerPaths) GetVideoPreviewPath(checksum string, seconds int) string {
|
||||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".mp4")
|
return filepath.Join(sp.GetFolderPath(checksum), strconv.Itoa(seconds)+".mp4")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *sceneMarkerPaths) GetWebpPreviewPath(checksum string, seconds int) string {
|
func (sp *sceneMarkerPaths) GetWebpPreviewPath(checksum string, seconds int) string {
|
||||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".webp")
|
return filepath.Join(sp.GetFolderPath(checksum), strconv.Itoa(seconds)+".webp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp *sceneMarkerPaths) GetScreenshotPath(checksum string, seconds int) string {
|
func (sp *sceneMarkerPaths) GetScreenshotPath(checksum string, seconds int) string {
|
||||||
return filepath.Join(sp.Markers, checksum, strconv.Itoa(seconds)+".jpg")
|
return filepath.Join(sp.GetFolderPath(checksum), strconv.Itoa(seconds)+".jpg")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ func MigrateHash(p *paths.Paths, oldHash string, newHash string) {
|
|||||||
oldPath = scenePaths.GetInteractiveHeatmapPath(oldHash)
|
oldPath = scenePaths.GetInteractiveHeatmapPath(oldHash)
|
||||||
newPath = scenePaths.GetInteractiveHeatmapPath(newHash)
|
newPath = scenePaths.GetInteractiveHeatmapPath(newHash)
|
||||||
migrateSceneFiles(oldPath, newPath)
|
migrateSceneFiles(oldPath, newPath)
|
||||||
|
|
||||||
|
// #3986 - migrate scene marker files
|
||||||
|
markerPaths := p.SceneMarkers
|
||||||
|
oldPath = markerPaths.GetFolderPath(oldHash)
|
||||||
|
newPath = markerPaths.GetFolderPath(newHash)
|
||||||
|
migrateSceneFolder(oldPath, newPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func migrateSceneFiles(oldName, newName string) {
|
func migrateSceneFiles(oldName, newName string) {
|
||||||
@@ -75,3 +81,18 @@ func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateSceneFolder(oldName, newName string) {
|
||||||
|
oldExists, err := fsutil.DirExists(oldName)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
logger.Errorf("Error checking existence of %s: %s", oldName, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if oldExists {
|
||||||
|
logger.Infof("renaming %s to %s", oldName, newName)
|
||||||
|
if err := os.Rename(oldName, newName); err != nil {
|
||||||
|
logger.Errorf("error renaming %s to %s: %s", oldName, newName, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user