Skip to content

Commit 63be230

Browse files
committed
Show upgrade dialog on storage limit errors
1 parent e509f8a commit 63be230

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • src/puter-js/src/modules/FileSystem/operations

src/puter-js/src/modules/FileSystem/operations/upload.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from '../../../lib/path.js';
22
import * as utils from '../../../lib/utils.js';
33
import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js';
4+
import { showUsageLimitDialog } from '../../../modules/UsageLimitDialog.js';
45

56
/* eslint-disable */
67
const MAX_THUMBNAIL_BYTES = 2 * 1024 * 1024;
@@ -358,6 +359,19 @@ const upload = async function (items, dirPath, options = {}) {
358359
}
359360

360361
const error = (e) => {
362+
// Check for storage limit errors and show upgrade dialog
363+
const isStorageError =
364+
e?.code === 'NOT_ENOUGH_SPACE' ||
365+
e?.status === 413 ||
366+
e?.code === 'storage_limit_reached';
367+
if ( isStorageError ) {
368+
if ( puter.env === 'web' ) {
369+
showUsageLimitDialog('Not enough storage space available.<br>Please upgrade to continue.');
370+
} else if ( puter.env === 'app' ) {
371+
puter.ui.requestUpgrade();
372+
}
373+
}
374+
361375
// if error callback is provided, call it
362376
if ( options.error && typeof options.error === 'function' )
363377
{

0 commit comments

Comments
 (0)