Implemented progressbar for export/import

This commit is contained in:
Philipp Wolfer 2023-11-16 00:45:00 +01:00
parent ab04eb1123
commit 6e330daf06
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
24 changed files with 590 additions and 239 deletions

View file

@ -52,7 +52,7 @@ func ResolveBackend[T interface{}](config *viper.Viper) (T, error) {
if err != nil {
return result, err
}
implements, interfaceName := implementsInterface[T](backend)
implements, interfaceName := ImplementsInterface[T](&backend)
if implements {
result = backend.(T)
} else {
@ -91,14 +91,14 @@ func resolveBackend(config *viper.Viper) (string, models.Backend, error) {
backendName := config.GetString("backend")
backendType := knownBackends[backendName]
if backendType == nil {
return backendName, nil, errors.New(fmt.Sprintf("Unknown backend %s", backendName))
return backendName, nil, fmt.Errorf("Unknown backend %s", backendName)
}
return backendName, backendType().FromConfig(config), nil
}
func implementsInterface[T interface{}](backend models.Backend) (bool, string) {
func ImplementsInterface[T interface{}](backend *models.Backend) (bool, string) {
expectedInterface := reflect.TypeOf((*T)(nil)).Elem()
implements := backend != nil && reflect.TypeOf(backend).Implements(expectedInterface)
implements := backend != nil && reflect.TypeOf(*backend).Implements(expectedInterface)
return implements, expectedInterface.Name()
}
@ -133,7 +133,7 @@ func getImportCapabilities(backend models.Backend) []Capability {
}
func checkCapability[T interface{}](backend models.Backend, suffix string) (string, bool) {
implements, name := implementsInterface[T](backend)
implements, name := ImplementsInterface[T](&backend)
if implements {
cap, found := strings.CutSuffix(strings.ToLower(name), suffix)
if found {