7253: update BlockIterWithDuplicates to return any errors through Manifest, rather...
[arvados.git] / services / datamanager / collection / collection.go
index 0d583c2c99845ffcbd0841b73e28a78ab90d1592..df6852687a621fccbb9606b99ae30cfa81bf3dca 100644 (file)
@@ -274,7 +274,7 @@ func ProcessCollections(arvLogger *logger.Logger,
                        collection.ReplicationLevel = defaultReplicationLevel
                }
 
-               manifest := manifest.Manifest{sdkCollection.ManifestText}
+               manifest := manifest.Manifest{Text: sdkCollection.ManifestText}
                manifestSize := uint64(len(sdkCollection.ManifestText))
 
                if _, alreadySeen := UUIDToCollection[collection.UUID]; !alreadySeen {
@@ -286,21 +286,22 @@ func ProcessCollections(arvLogger *logger.Logger,
 
                blockChannel := manifest.BlockIterWithDuplicates()
                for block := range blockChannel {
-                       if block.Err != nil {
-                               err = block.Err
-                               return
-                       }
-                       if storedSize, stored := collection.BlockDigestToSize[block.Locator.Digest]; stored && storedSize != block.Locator.Size {
+                       if storedSize, stored := collection.BlockDigestToSize[block.Digest]; stored && storedSize != block.Size {
                                err = fmt.Errorf(
                                        "Collection %s contains multiple sizes (%d and %d) for block %s",
                                        collection.UUID,
                                        storedSize,
-                                       block.Locator.Size,
-                                       block.Locator.Digest)
+                                       block.Size,
+                                       block.Digest)
                                return
                        }
-                       collection.BlockDigestToSize[block.Locator.Digest] = block.Locator.Size
+                       collection.BlockDigestToSize[block.Digest] = block.Size
                }
+               if manifest.Err != nil {
+                       err = manifest.Err
+                       return
+               }
+
                collection.TotalSize = 0
                for _, size := range collection.BlockDigestToSize {
                        collection.TotalSize += size