File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -323,7 +323,24 @@ async function processFilePatch(
323323 let result = true
324324 try {
325325 await fs . copyFile ( blobPath , filepath )
326- logger . success ( `Patch applied successfully` )
326+
327+ // Verify the hash after copying to ensure file integrity.
328+ const verifyHashResult = await computeSHA256 ( filepath )
329+ if ( ! verifyHashResult . ok ) {
330+ logger . error (
331+ `Failed to verify hash after patch: ${ verifyHashResult . cause || verifyHashResult . message } ` ,
332+ )
333+ result = false
334+ } else if ( verifyHashResult . data !== fileInfo . afterHash ) {
335+ logger . error ( `Hash verification failed after patch` )
336+ logger . group ( )
337+ logger . log ( `Expected: ${ fileInfo . afterHash } ` )
338+ logger . log ( `Got: ${ verifyHashResult . data } ` )
339+ logger . groupEnd ( )
340+ result = false
341+ } else {
342+ logger . success ( `Patch applied successfully` )
343+ }
327344 } catch ( e ) {
328345 logger . error ( 'Error applying patch' )
329346 debugDir ( 'error' , e )
You can’t perform that action at this time.
0 commit comments