set default version as 0 and corrected version check

This commit is contained in:
Abhinav-grd 2021-01-24 19:35:18 +05:30
parent 0a8f5ab7d0
commit b5f05b0afd
2 changed files with 4 additions and 3 deletions

View file

@ -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,
);
}

View file

@ -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(