Rename marker folders when hash changes (#3988)

This commit is contained in:
WithoutPants
2023-08-02 16:15:37 +10:00
committed by GitHub
parent bd28aa6fd9
commit 107d1113e5
2 changed files with 28 additions and 3 deletions

View File

@@ -40,6 +40,12 @@ func MigrateHash(p *paths.Paths, oldHash string, newHash string) {
oldPath = scenePaths.GetInteractiveHeatmapPath(oldHash)
newPath = scenePaths.GetInteractiveHeatmapPath(newHash)
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) {
@@ -75,3 +81,18 @@ func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
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())
}
}
}