2019-01-06 06:44:33 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/filebrowser/filebrowser/v2/storage/bolt/importer"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
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", "", "")
|
|
|
|
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-01-07 05:34:56 +08:00
|
|
|
Use: "upgrade",
|
|
|
|
Version: rootCmd.Version,
|
|
|
|
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)
|
|
|
|
},
|
|
|
|
}
|