From db475864247b7afed5defc4e37ce1664c74433f3 Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Sun, 14 Feb 2021 23:45:38 +0530 Subject: [PATCH] Don't rely on cache that does not exist yet --- lib/models/collection.dart | 2 +- lib/services/collections_service.dart | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/models/collection.dart b/lib/models/collection.dart index 8595d711f..e4a0e8ed4 100644 --- a/lib/models/collection.dart +++ b/lib/models/collection.dart @@ -203,7 +203,7 @@ class CollectionAttributes { if (pathDecryptionNonce != null) { map['pathDecryptionNonce'] = pathDecryptionNonce; } - if (version != null) map['version'] = version; + map['version'] = version ?? 0; return map; } diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index e8f425d59..4eb3350fa 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -260,9 +260,10 @@ class CollectionsService { Sodium.bin2base64(encryptedPath.nonce), CollectionType.folder, CollectionAttributes( - encryptedPath: Sodium.bin2base64(encryptedPath.encryptedData), - pathDecryptionNonce: Sodium.bin2base64(encryptedPath.nonce), - version: 1), + encryptedPath: Sodium.bin2base64(encryptedPath.encryptedData), + pathDecryptionNonce: Sodium.bin2base64(encryptedPath.nonce), + version: 1, + ), null, null, )); @@ -347,7 +348,7 @@ class CollectionsService { String decryptCollectionPath(Collection collection) { final key = collection.attributes.version == 1 - ? getCollectionKey(collection.id) + ? _getDecryptedKey(collection) : _config.getKey(); return utf8.decode(CryptoUtil.decryptSync( Sodium.base642bin(collection.attributes.encryptedPath),