fix(import): don't fail when importing from dev exports
This commit is contained in:
parent
2c0c3ea24e
commit
ce3a06f03b
@ -30,6 +30,7 @@ import (
|
|||||||
"code.vikunja.io/api/pkg/models"
|
"code.vikunja.io/api/pkg/models"
|
||||||
"code.vikunja.io/api/pkg/modules/migration"
|
"code.vikunja.io/api/pkg/modules/migration"
|
||||||
"code.vikunja.io/api/pkg/user"
|
"code.vikunja.io/api/pkg/user"
|
||||||
|
vversion "code.vikunja.io/api/pkg/version"
|
||||||
|
|
||||||
"github.com/hashicorp/go-version"
|
"github.com/hashicorp/go-version"
|
||||||
)
|
)
|
||||||
@ -119,17 +120,22 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er
|
|||||||
return fmt.Errorf("could not read version file: %w", err)
|
return fmt.Errorf("could not read version file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dumpedVersion, err := version.NewVersion(bufVersion.String())
|
versionString := bufVersion.String()
|
||||||
if err != nil {
|
if versionString == "dev" && versionString == vversion.Version {
|
||||||
return err
|
log.Debugf(logPrefix + "Importing from dev version")
|
||||||
}
|
} else {
|
||||||
minVersion, err := version.NewVersion("0.20.1+61")
|
dumpedVersion, err := version.NewVersion(bufVersion.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
minVersion, err := version.NewVersion("0.20.1+61")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if dumpedVersion.LessThan(minVersion) {
|
if dumpedVersion.LessThan(minVersion) {
|
||||||
return fmt.Errorf("export was created with an older version, need at least %s but the export needs at least %s", dumpedVersion, minVersion)
|
return fmt.Errorf("export was created with an older version, need at least %s but the export needs at least %s", dumpedVersion, minVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user