fix: ensure we migrate data for all golang plugins
This commit is contained in:
@@ -139,7 +139,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
||||
|
||||
// TriggerPostAppRename removes the old app data
|
||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||
return common.RemoveAppDataDirectory("app-json", oldAppName)
|
||||
return common.MigrateAppDataDirectory("app-json", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostAppRenameSetup renames app-json files
|
||||
@@ -162,7 +162,7 @@ func TriggerPostCreate(appName string) error {
|
||||
|
||||
// TriggerPostDelete destroys the app-json data for a given app container
|
||||
func TriggerPostDelete(appName string) error {
|
||||
dataErr := os.RemoveAll(common.GetAppDataDirectory("app-json", appName))
|
||||
dataErr := common.RemoveAppDataDirectory("app-json", appName)
|
||||
propertyErr := common.PropertyDestroy("app-json", appName)
|
||||
|
||||
if dataErr != nil {
|
||||
|
||||
@@ -46,6 +46,15 @@ func GetDataDirectory(pluginName string) string {
|
||||
return filepath.Join(MustGetEnv("DOKKU_LIB_ROOT"), "data", pluginName)
|
||||
}
|
||||
|
||||
// MigrateAppDataDirectory migrates the data directory for one app to another
|
||||
func MigrateAppDataDirectory(pluginName string, oldAppName string, newAppName string) error {
|
||||
if err := CloneAppData(pluginName, oldAppName, newAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return RemoveAppDataDirectory(pluginName, oldAppName)
|
||||
}
|
||||
|
||||
// RemoveAppDataDirectory removes the path to the data directory for the given plugin/app combination
|
||||
func RemoveAppDataDirectory(pluginName, appName string) error {
|
||||
return os.RemoveAll(GetAppDataDirectory(pluginName, appName))
|
||||
|
||||
@@ -118,7 +118,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
||||
|
||||
// TriggerPostAppRename removes the old app data
|
||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||
return common.RemoveAppDataDirectory("logs", oldAppName)
|
||||
return common.MigrateAppDataDirectory("logs", oldAppName, newAppName)
|
||||
}
|
||||
|
||||
// TriggerPostAppRenameSetup renames logs files
|
||||
@@ -141,7 +141,7 @@ func TriggerPostCreate(appName string) error {
|
||||
|
||||
// TriggerPostDelete destroys the logs property for a given app container
|
||||
func TriggerPostDelete(appName string) error {
|
||||
dataErr := os.RemoveAll(common.GetAppDataDirectory("logs", appName))
|
||||
dataErr := common.RemoveAppDataDirectory("logs", appName)
|
||||
propertyErr := common.PropertyDestroy("logs", appName)
|
||||
|
||||
if dataErr != nil {
|
||||
|
||||
@@ -182,7 +182,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
||||
|
||||
// TriggerPostAppRename rebuilds the renamed app
|
||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||
if err := common.RemoveAppDataDirectory("ps", oldAppName); err != nil {
|
||||
if err := common.MigrateAppDataDirectory("ps", oldAppName, newAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user