fix: convert all app creation timestamps over to the properties system
This commit is contained in:
1 parent
9506ba727e
commit
cb3b3b650d
1 file changed
+28
@@ -2,6 +2,8 @@ package apps
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
)
|
)
|
||||||
@@ -41,6 +43,32 @@ func TriggerInstall() error {
|
|||||||
return fmt.Errorf("Unable to install the apps plugin: %s", err.Error())
|
return fmt.Errorf("Unable to install the apps plugin: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apps, err := common.UnfilteredDokkuApps()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// migrate all created-at values from app mod-time to property
|
||||||
|
for _, appName := range apps {
|
||||||
|
if common.PropertyExists("apps", appName, "created-at") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
fi, err := os.Stat(common.AppRoot(appName))
|
||||||
|
if err != nil {
|
||||||
|
// if we can't get the time, just write the current one out as a stub
|
||||||
|
if err := common.PropertyWrite("apps", appName, "created-at", fmt.Sprintf("%d", time.Now().Unix())); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := common.PropertyWrite("apps", appName, "created-at", fmt.Sprintf("%d", fi.ModTime().Unix())); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user