Fix sync error

This commit is contained in:
Bernd Schoolmann 2024-04-05 08:06:02 +02:00
parent f798ef3825
commit 24f6907c0d
No known key found for this signature in database
1 changed files with 1 additions and 17 deletions

View File

@ -16,20 +16,12 @@ import (
var log = logging.GetLogger("Goldwarden", "Bitwarden API")
const path = "/.cache/goldwarden-vault.json"
func Sync(ctx context.Context, config *config.Config) (models.SyncData, error) {
var sync models.SyncData
if err := authenticatedHTTPGet(ctx, config.ConfigFile.ApiUrl+"/sync", &sync); err != nil {
return models.SyncData{}, fmt.Errorf("could not sync: %v", err)
}
home, _ := os.UserHomeDir()
err := WriteVault(sync, home+path)
if err != nil {
return sync, err
}
return sync, nil
}
@ -38,15 +30,7 @@ func DoFullSync(ctx context.Context, vault *vault.Vault, config *config.Config,
sync, err := Sync(ctx, config)
if err != nil {
log.Error("Could not sync: %v", err)
if allowCache {
home, _ := os.UserHomeDir()
sync, err = ReadVault(home + path)
if err != nil {
return err
}
} else {
return err
}
return err
} else {
log.Info("Sync successful, initializing keyring and vault...")
}