@@ -15,11 +15,14 @@ function sendStoredFile(request, response) {
1515 return segment !== '' ;
1616 } ) ;
1717
18+
1819 const version = filePathSegments [ 0 ] ;
1920 const isDocsPath = filePathSegments [ 1 ] === 'docs' ;
2021 const lastSegment = filePathSegments [ filePathSegments . length - 1 ] ;
2122 const bucket = gcs . bucket ( gcsBucketId ) ;
2223
24+ console . log ( request . path , lastSegment ) ;
25+
2326 let downloadSource ;
2427 let fileName ;
2528
@@ -190,9 +193,7 @@ const snapshotRegex = /^snapshot(-stable)?\//;
190193 * When a new zip file is uploaded into snapshot or snapshot-stable,
191194 * delete the previous zip file.
192195 */
193- function deleteOldSnapshotZip ( event ) {
194- const object = event . data ;
195-
196+ function deleteOldSnapshotZip ( object , context ) {
196197 const bucketId = object . bucket ;
197198 const filePath = object . name ;
198199 const contentType = object . contentType ;
@@ -202,13 +203,6 @@ function deleteOldSnapshotZip(event) {
202203
203204 const snapshotFolderMatch = filePath . match ( snapshotRegex ) ;
204205
205- if ( ! snapshotFolderMatch ||
206- contentType !== 'application/zip' ||
207- resourceState === 'not_exists' // Deletion event
208- ) {
209- return ;
210- }
211-
212206 bucket . getFiles ( {
213207 prefix : snapshotFolderMatch [ 0 ] ,
214208 delimiter : '/' ,
@@ -230,4 +224,4 @@ function deleteOldSnapshotZip(event) {
230224}
231225
232226exports . sendStoredFile = functions . https . onRequest ( sendStoredFile ) ;
233- exports . deleteOldSnapshotZip = functions . storage . object ( ) . onChange ( deleteOldSnapshotZip ) ;
227+ exports . deleteOldSnapshotZip = functions . storage . object ( ) . onFinalize ( deleteOldSnapshotZip ) ;
0 commit comments