mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-24 21:47:55 +02:00
Implemented progressbar for export/import
This commit is contained in:
parent
ab04eb1123
commit
6e330daf06
24 changed files with 590 additions and 239 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue