@@ -78,6 +78,12 @@ export class StorageClient {
78
78
? await this . uploadImmutableFile ( file , acl )
79
79
: await this . uploadMutableFile ( file , acl ) ;
80
80
81
+ await this . waitUntilStatus (
82
+ resource . storageKey ,
83
+ [ 'done' , 'available' ] ,
84
+ this . env . cachingTimeout ,
85
+ ) ;
86
+
81
87
return new FileUploadResponse ( resource , this ) ;
82
88
}
83
89
@@ -140,9 +146,9 @@ export class StorageClient {
140
146
files : FileList | File [ ] ,
141
147
options : UploadFolderOptions = { acl : immutable ( this . env . defaultChainId ) } ,
142
148
) : Promise < UploadFolderResponse > {
143
- const needsIndex = 'index' in options && ! ! options . index ;
149
+ const withIndexFile = 'index' in options && ! ! options . index ;
144
150
const [ folderResource , ...fileResources ] = await this . allocateStorage (
145
- files . length + ( needsIndex ? 2 : 1 ) ,
151
+ files . length + ( withIndexFile ? 2 : 1 ) ,
146
152
) ;
147
153
148
154
const builder = MultipartEntriesBuilder . from ( fileResources ) . withFiles (
@@ -162,6 +168,13 @@ export class StorageClient {
162
168
throw await StorageClientError . fromResponse ( response ) ;
163
169
}
164
170
171
+ await this . waitUntilStatus (
172
+ // biome-ignore lint/style/noNonNullAssertion: we know the folder has at least one file
173
+ withIndexFile ? folderResource . storageKey : fileResources [ 0 ] ! . storageKey ,
174
+ [ 'done' , 'available' ] ,
175
+ this . env . cachingTimeout ,
176
+ ) ;
177
+
165
178
return {
166
179
folder : folderResource ,
167
180
files : fileResources ,
@@ -317,8 +330,6 @@ export class StorageClient {
317
330
while ( Date . now ( ) - startedAt < timeout ) {
318
331
const { status } = await this . status ( storageKeyOrUri ) ;
319
332
320
- console . log ( storageKeyOrUri , status ) ;
321
-
322
333
// Handle common error states
323
334
switch ( status ) {
324
335
case 'error_upload' :
@@ -401,21 +412,11 @@ export class StorageClient {
401
412
storageKey : string ,
402
413
entries : readonly MultipartEntry [ ] ,
403
414
) : Promise < Response > {
404
- const response = await this . multipartRequest (
415
+ return this . multipartRequest (
405
416
'POST' ,
406
417
`${ this . env . backend } /${ storageKey } ` ,
407
418
entries ,
408
419
) ;
409
-
410
- console . log ( 'upload' , `${ this . env . backend } /${ storageKey } ` ) ;
411
-
412
- await this . waitUntilStatus (
413
- storageKey ,
414
- [ 'done' , 'available' ] ,
415
- this . env . cachingTimeout ,
416
- ) ;
417
-
418
- return response ;
419
420
}
420
421
421
422
private async update (
0 commit comments