@@ -40,15 +40,13 @@ class HashService {
40
40
);
41
41
hashesInDB.sort ((a, b) => a.assetId.compareTo (b.assetId));
42
42
43
- int assetIndex = 0 ;
44
43
int dbIndex = 0 ;
45
-
46
44
int bytesProcessed = 0 ;
47
45
final hashedAssets = < Asset > [];
48
46
final toBeHashed = < _AssetPath > [];
49
47
final toBeDeleted = < String > [];
50
48
51
- while ( assetIndex < assets.length) {
49
+ for ( int assetIndex = 0 ; assetIndex < assets.length; assetIndex ++ ) {
52
50
final asset = assets[assetIndex];
53
51
DeviceAsset ? matchingDbEntry;
54
52
@@ -67,7 +65,6 @@ class HashService {
67
65
hashedAssets.add (
68
66
asset.copyWith (checksum: base64.encode (matchingDbEntry.hash)),
69
67
);
70
- assetIndex++ ;
71
68
continue ;
72
69
}
73
70
@@ -77,19 +74,18 @@ class HashService {
77
74
if (matchingDbEntry != null ) {
78
75
toBeDeleted.add (matchingDbEntry.assetId);
79
76
}
80
- } else {
81
- bytesProcessed += await file.length ();
82
- toBeHashed.add (_AssetPath (asset: asset, path: file.path));
83
-
84
- if (_shouldProcessBatch (toBeHashed.length, bytesProcessed)) {
85
- hashedAssets.addAll (await _processBatch (toBeHashed, toBeDeleted));
86
- toBeHashed.clear ();
87
- toBeDeleted.clear ();
88
- bytesProcessed = 0 ;
89
- }
77
+ continue ;
90
78
}
91
79
92
- assetIndex++ ;
80
+ bytesProcessed += await file.length ();
81
+ toBeHashed.add (_AssetPath (asset: asset, path: file.path));
82
+
83
+ if (_shouldProcessBatch (toBeHashed.length, bytesProcessed)) {
84
+ hashedAssets.addAll (await _processBatch (toBeHashed, toBeDeleted));
85
+ toBeHashed.clear ();
86
+ toBeDeleted.clear ();
87
+ bytesProcessed = 0 ;
88
+ }
93
89
}
94
90
assert (dbIndex == hashesInDB.length, "All hashes should've been processed" );
95
91
0 commit comments