@@ -15,11 +15,14 @@ function sendStoredFile(request, response) {
15
15
return segment !== '' ;
16
16
} ) ;
17
17
18
+
18
19
const version = filePathSegments [ 0 ] ;
19
20
const isDocsPath = filePathSegments [ 1 ] === 'docs' ;
20
21
const lastSegment = filePathSegments [ filePathSegments . length - 1 ] ;
21
22
const bucket = gcs . bucket ( gcsBucketId ) ;
22
23
24
+ console . log ( request . path , lastSegment ) ;
25
+
23
26
let downloadSource ;
24
27
let fileName ;
25
28
@@ -190,9 +193,7 @@ const snapshotRegex = /^snapshot(-stable)?\//;
190
193
* When a new zip file is uploaded into snapshot or snapshot-stable,
191
194
* delete the previous zip file.
192
195
*/
193
- function deleteOldSnapshotZip ( event ) {
194
- const object = event . data ;
195
-
196
+ function deleteOldSnapshotZip ( object , context ) {
196
197
const bucketId = object . bucket ;
197
198
const filePath = object . name ;
198
199
const contentType = object . contentType ;
@@ -202,13 +203,6 @@ function deleteOldSnapshotZip(event) {
202
203
203
204
const snapshotFolderMatch = filePath . match ( snapshotRegex ) ;
204
205
205
- if ( ! snapshotFolderMatch ||
206
- contentType !== 'application/zip' ||
207
- resourceState === 'not_exists' // Deletion event
208
- ) {
209
- return ;
210
- }
211
-
212
206
bucket . getFiles ( {
213
207
prefix : snapshotFolderMatch [ 0 ] ,
214
208
delimiter : '/' ,
@@ -230,4 +224,4 @@ function deleteOldSnapshotZip(event) {
230
224
}
231
225
232
226
exports . sendStoredFile = functions . https . onRequest ( sendStoredFile ) ;
233
- exports . deleteOldSnapshotZip = functions . storage . object ( ) . onChange ( deleteOldSnapshotZip ) ;
227
+ exports . deleteOldSnapshotZip = functions . storage . object ( ) . onFinalize ( deleteOldSnapshotZip ) ;
0 commit comments