@@ -279,18 +279,6 @@ Example:
279279 return fmt .Errorf ("failed to decrypt chunk %s: %v" , chunkHash , err )
280280 }
281281
282- // Verify chunk integrity if not skipped
283- skipVerify , _ := cmd .Flags ().GetBool (skipVerification )
284- if ! skipEncryption && ! skipVerify && chunkRef .Hash != "" {
285- if err := verifyChunkWithRetry (ctx , chunkRef , decryptedData , 3 ); err != nil {
286- progressMgr .PrintVerbose ("Chunk %s failed integrity verification: %v\n " , chunkHash , err )
287- return fmt .Errorf ("chunk %s integrity verification failed after retries: %v" , chunkHash , err )
288- }
289- progressMgr .PrintVerbose ("Chunk %s integrity verified successfully\n " , chunkHash )
290- } else if skipVerify {
291- progressMgr .PrintVerbose ("Skipping integrity verification for chunk %s (--skip-verification flag used)\n " , chunkHash )
292- }
293-
294282 // The original data was base64-encoded before encryption. Decode back to bytes.
295283 decodedBytes , err := base64 .StdEncoding .DecodeString (decryptedData )
296284 if err != nil {
@@ -315,6 +303,17 @@ Example:
315303 chunkData = decompressedData
316304 }
317305
306+ skipVerify , _ := cmd .Flags ().GetBool (skipVerification )
307+ if ! skipEncryption && ! skipVerify && chunkRef .Hash != "" {
308+ if err := verifyChunkWithRetry (ctx , chunkRef , string (chunkData ), 3 ); err != nil {
309+ progressMgr .PrintVerbose ("Chunk %s failed integrity verification: %v\n " , chunkHash , err )
310+ return fmt .Errorf ("chunk %s integrity verification failed after retries: %v" , chunkHash , err )
311+ }
312+ progressMgr .PrintVerbose ("Chunk %s integrity verified successfully\n " , chunkHash )
313+ } else if skipVerify {
314+ progressMgr .PrintVerbose ("Skipping integrity verification for chunk %s (--skip-verification flag used)\n " , chunkHash )
315+ }
316+
318317 // Write the chunk to the output file
319318 bytesWritten , err := outputFile .Write (chunkData )
320319 if err != nil {
0 commit comments