2019-01-06 06:44:33 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
2020-06-01 07:12:36 +08:00
|
|
|
|
|
|
|
"github.com/filebrowser/filebrowser/v2/storage/bolt/importer"
|
2019-01-06 06:44:33 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-01-08 03:22:32 +08:00
|
|
|
rootCmd.AddCommand(upgradeCmd)
|
2019-01-06 06:44:33 +08:00
|
|
|
|
2019-01-08 03:22:32 +08:00
|
|
|
upgradeCmd.Flags().String("old.database", "", "")
|
|
|
|
upgradeCmd.Flags().String("old.config", "", "")
|
2020-06-01 07:12:36 +08:00
|
|
|
_ = upgradeCmd.MarkFlagRequired("old.database")
|
2019-01-06 06:44:33 +08:00
|
|
|
}
|
|
|
|
|
2019-01-08 03:22:32 +08:00
|
|
|
var upgradeCmd = &cobra.Command{
|
2019-02-15 19:54:44 +08:00
|
|
|
Use: "upgrade",
|
|
|
|
Short: "Upgrades an old configuration",
|
2019-01-08 03:22:32 +08:00
|
|
|
Long: `Upgrades an old configuration. This command DOES NOT
|
2019-01-06 06:44:33 +08:00
|
|
|
import share links because they are incompatible with
|
|
|
|
this version.`,
|
2019-01-06 07:01:16 +08:00
|
|
|
Args: cobra.NoArgs,
|
2019-01-06 06:44:33 +08:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2019-01-08 22:07:55 +08:00
|
|
|
flags := cmd.Flags()
|
|
|
|
oldDB := mustGetString(flags, "old.database")
|
|
|
|
oldConf := mustGetString(flags, "old.config")
|
2019-01-09 04:10:27 +08:00
|
|
|
err := importer.Import(oldDB, oldConf, getParam(flags, "database"))
|
2019-01-06 06:44:33 +08:00
|
|
|
checkErr(err)
|
|
|
|
},
|
|
|
|
}
|