Skip to content

Commit 5cd17a5

Browse files
committed
refactor(provider): make optimistic arg optional
1 parent 02ed8da commit 5cd17a5

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/providers/interface/src/provider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ export abstract class StorageServiceProvider<ID> {
1212
expiresIn: ExpiresIn
1313
): SignedUploadUrlRequest<ID>
1414

15-
abstract getData(fileId: ID, optimistic: boolean): GetDataRequest<ID>
15+
/**
16+
*
17+
* @param fileId
18+
* @param optimistic If true, the provider will return the data without checking the existence of the file
19+
*/
20+
abstract getData(fileId: ID, optimistic?: boolean): GetDataRequest<ID>
1621

1722
abstract delete(fileId: ID): DeleteRequest
1823
}

packages/providers/s3/src/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class S3Provider<ID> extends StorageServiceProvider<ID> {
117117
return []
118118
}
119119

120-
async getData(fileId: ID, optimistic: boolean): GetDataRequest<ID> {
120+
async getData(fileId: ID, optimistic = false): GetDataRequest<ID> {
121121
// TODO: Refactor the file check
122122

123123
const variants = await this.createFileUrls(fileId, optimistic)

packages/server/core/src/upload-wizard.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ export class UploadWizard<ID = DefaultID> {
6565
throw new Error('Invalid confirm token')
6666
}
6767

68-
const { status } = await this.storageServiceProvider.getData(
69-
imageId,
70-
false
71-
)
68+
const { status } = await this.storageServiceProvider.getData(imageId)
7269

7370
if (status === FileStatus.NOT_FOUND) {
7471
throw new Error('File not found')

0 commit comments

Comments
 (0)