fix(nbstore): improve blob size error handling with human-readable limit (#12027)

Closes: [BS-3332](https://linear.app/affine-design/issue/BS-3332/错误信息)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Bug Fixes**
	- Improved error messages when file uploads exceed the allowed size, now showing the maximum file size limit in a human-readable format.
	- Enhanced status updates for oversized files by displaying clear error messages during blob uploads.
- **Style**
	- Error messages for file size limits are now more user-friendly and informative.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fundon
2025-05-07 01:29:37 +00:00
parent ad7868633d
commit 9702d45c9b
4 changed files with 17 additions and 9 deletions
@@ -185,8 +185,7 @@ export class BlobSyncPeer {
this.status.remoteOverCapacity();
this.status.blobError(blob.key, 'Remote storage over capacity');
} else if (err instanceof OverSizeError) {
this.status.blobOverSize(blob.key);
this.status.blobError(blob.key, 'Blob size too large');
this.status.blobOverSizeWithError(blob.key, err.message);
} else {
this.status.blobError(
blob.key,
@@ -445,7 +444,6 @@ class BlobSyncPeerStatus {
if (deleted) {
this.statusUpdatedSubject$.next(blobId);
}
this.blobErrorFree(blobId);
}
blobWillUpload(blobId: string) {
@@ -517,6 +515,12 @@ class BlobSyncPeerStatus {
this.statusUpdatedSubject$.next(blobId);
}
blobOverSizeWithError(blobId: string, errorMessage: string) {
this.overSize.add(blobId);
this.error.set(blobId, errorMessage);
this.statusUpdatedSubject$.next(blobId);
}
blobErrorFree(blobId: string) {
let deleted = false;
deleted = this.error.delete(blobId) || deleted;