From b5f05b0afd6463897044647abd1e73a459062adc Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 24 Jan 2021 19:35:18 +0530 Subject: [PATCH] set default version as 0 and corrected version check --- lib/models/collection.dart | 5 +++-- lib/services/collections_service.dart | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/models/collection.dart b/lib/models/collection.dart index 6686fec2d..8595d711f 100644 --- a/lib/models/collection.dart +++ b/lib/models/collection.dart @@ -180,7 +180,7 @@ class CollectionAttributes { CollectionAttributes({ this.encryptedPath, this.pathDecryptionNonce, - this.version = 0, + this.version, }); CollectionAttributes copyWith({ @@ -203,6 +203,7 @@ class CollectionAttributes { if (pathDecryptionNonce != null) { map['pathDecryptionNonce'] = pathDecryptionNonce; } + if (version != null) map['version'] = version; return map; } @@ -212,7 +213,7 @@ class CollectionAttributes { return CollectionAttributes( encryptedPath: map['encryptedPath'], pathDecryptionNonce: map['pathDecryptionNonce'], - version: map['version'], + version: map['version'] ?? 0, ); } diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index cbde2f33a..266057b38 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -321,7 +321,7 @@ class CollectionsService { } String decryptCollectionPath(Collection collection) { - final key = collection.attributes.version == 0 + final key = collection.attributes.version == 1 ? getCollectionKey(collection.id) : _config.getKey(); return utf8.decode(CryptoUtil.decryptSync(