fix: remove the per-app property folder on app delete and rename
Switches the storage plugin's post-delete and post-app-rename-setup triggers from rewriting the attachment list as empty to removing the per-app property folder outright via PropertyDestroy. This matches the convention other plugins use on app deletion and avoids leaving an empty mounts file behind for an app that no longer exists.
This commit is contained in:
1 file changed
+7
-11
@@ -58,19 +58,15 @@ func TriggerInstall() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TriggerPostDelete clears any attachment list for an app that's being
|
// TriggerPostDelete removes the attachment store for an app that's being
|
||||||
// destroyed. Entries are global and survive app deletion. Skipped when
|
// destroyed. Entries are global and survive app deletion. The whole
|
||||||
// the app has no attachments to begin with so we don't trigger a
|
// per-app property folder goes away rather than being rewritten as
|
||||||
// pointless propertyTouch that could fail on installs with no
|
// empty, matching what other plugins do on app deletion.
|
||||||
// property-list state for this plugin yet.
|
|
||||||
func TriggerPostDelete(appName string) error {
|
func TriggerPostDelete(appName string) error {
|
||||||
if appName == "" {
|
if appName == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !common.PropertyExists(PluginName, appName, AttachmentsProperty) {
|
return common.PropertyDestroy(PluginName, appName)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return common.PropertyListWrite(PluginName, appName, AttachmentsProperty, []string{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TriggerPostAppCloneSetup copies attachments from the source app to the
|
// TriggerPostAppCloneSetup copies attachments from the source app to the
|
||||||
@@ -90,7 +86,7 @@ func TriggerPostAppCloneSetup(oldName string, newName string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TriggerPostAppRenameSetup moves attachments from the old name to the
|
// TriggerPostAppRenameSetup moves attachments from the old name to the
|
||||||
// new name and clears the old.
|
// new name and removes the old per-app property folder.
|
||||||
func TriggerPostAppRenameSetup(oldName string, newName string) error {
|
func TriggerPostAppRenameSetup(oldName string, newName string) error {
|
||||||
if oldName == "" || newName == "" {
|
if oldName == "" || newName == "" {
|
||||||
return nil
|
return nil
|
||||||
@@ -105,7 +101,7 @@ func TriggerPostAppRenameSetup(oldName string, newName string) error {
|
|||||||
if err := SaveAttachments(newName, attachments); err != nil {
|
if err := SaveAttachments(newName, attachments); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return common.PropertyListWrite(PluginName, oldName, AttachmentsProperty, []string{})
|
return common.PropertyDestroy(PluginName, oldName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// detectDistro returns the Linux distribution name
|
// detectDistro returns the Linux distribution name
|
||||||
|
|||||||
Reference in new issue
Block a user