Bläddra i källkod

set default version as 0 and corrected version check

Abhinav-grd 4 år sedan
förälder
incheckning
b5f05b0afd
2 ändrade filer med 4 tillägg och 3 borttagningar
  1. 3 2
      lib/models/collection.dart
  2. 1 1
      lib/services/collections_service.dart

+ 3 - 2
lib/models/collection.dart

@@ -180,7 +180,7 @@ class CollectionAttributes {
   CollectionAttributes({
   CollectionAttributes({
     this.encryptedPath,
     this.encryptedPath,
     this.pathDecryptionNonce,
     this.pathDecryptionNonce,
-    this.version = 0,
+    this.version,
   });
   });
 
 
   CollectionAttributes copyWith({
   CollectionAttributes copyWith({
@@ -203,6 +203,7 @@ class CollectionAttributes {
     if (pathDecryptionNonce != null) {
     if (pathDecryptionNonce != null) {
       map['pathDecryptionNonce'] = pathDecryptionNonce;
       map['pathDecryptionNonce'] = pathDecryptionNonce;
     }
     }
+    if (version != null) map['version'] = version;
     return map;
     return map;
   }
   }
 
 
@@ -212,7 +213,7 @@ class CollectionAttributes {
     return CollectionAttributes(
     return CollectionAttributes(
       encryptedPath: map['encryptedPath'],
       encryptedPath: map['encryptedPath'],
       pathDecryptionNonce: map['pathDecryptionNonce'],
       pathDecryptionNonce: map['pathDecryptionNonce'],
-      version: map['version'],
+      version: map['version'] ?? 0,
     );
     );
   }
   }
 
 

+ 1 - 1
lib/services/collections_service.dart

@@ -321,7 +321,7 @@ class CollectionsService {
   }
   }
 
 
   String decryptCollectionPath(Collection collection) {
   String decryptCollectionPath(Collection collection) {
-    final key = collection.attributes.version == 0
+    final key = collection.attributes.version == 1
         ? getCollectionKey(collection.id)
         ? getCollectionKey(collection.id)
         : _config.getKey();
         : _config.getKey();
     return utf8.decode(CryptoUtil.decryptSync(
     return utf8.decode(CryptoUtil.decryptSync(