@@ -66,6 +66,7 @@ export interface PublishHandler<
6666 createDeploy : (
6767 siteId : string ,
6868 files : Record < string , string > ,
69+ size : number ,
6970 ) => Promise < Deploy > ;
7071 getDeploy : ( deployId : string ) => Promise < Deploy > ;
7172 uploadDeployFile : (
@@ -132,12 +133,12 @@ export async function handlePublish<
132133 message : `Preparing to publish ${ type } ` ,
133134 } , async ( ) => {
134135 const textDecoder = new TextDecoder ( ) ;
136+ let size = 0 ;
135137 for ( const file of publishFiles . files ) {
136138 const filePath = publishFilePath ( file ) ;
137- const sha1 = await crypto . subtle . digest (
138- "SHA-1" ,
139- Deno . readFileSync ( filePath ) ,
140- ) ;
139+ const fileBuffer = Deno . readFileSync ( filePath ) ;
140+ size = size + fileBuffer . byteLength ;
141+ const sha1 = await crypto . subtle . digest ( "SHA-1" , fileBuffer ) ;
141142 const encodedSha1 = hexEncode ( new Uint8Array ( sha1 ) ) ;
142143 files . push ( [ file , textDecoder . decode ( encodedSha1 ) ] ) ;
143144 }
@@ -149,7 +150,11 @@ export async function handlePublish<
149150 for ( const file of files ) {
150151 deploy . files [ `/${ file [ 0 ] } ` ] = file [ 1 ] ;
151152 }
152- siteDeploy = await handler . createDeploy ( target ! . id , deploy . files ) ;
153+ siteDeploy = await handler . createDeploy (
154+ target ! . id ,
155+ deploy . files ,
156+ size ,
157+ ) ;
153158
154159 // wait for it to be ready
155160 while ( true ) {
0 commit comments