Skip to content

Commit

Permalink
Add check for exceeded storage quota
Browse files Browse the repository at this point in the history
Previous check only contained size of selected files,
but did not consider already used storage.
  • Loading branch information
lehecht committed May 13, 2024
1 parent 7010bb4 commit 64ee390
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/resources/assets/js/createContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export default {
return sizeForHumans(this.uploadedSize);
},
exceedsMaxSize() {
return this.availableQuotaBytes !== -1 && this.totalSize() > this.availableQuotaBytes;
let selectionExceedsQuota = this.availableQuotaBytes !== -1 && this.totalSize() > this.availableQuotaBytes;
let exceedsStorage = this.availableQuotaBytes !== -1 && this.usedQuota !== -1 && this.totalSize() + this.usedQuota > this.availableQuotaBytes;
return selectionExceedsQuota || exceedsStorage;
},
canSubmit() {
return this.hasFiles && !this.exceedsMaxSize;
Expand All @@ -82,7 +84,9 @@ export default {
},
methods: {
noFilesUploaded() {
return (this.nbrDuplicatedFiles === this.files.length) || (this.getFailedFiles().length === this.files.length);
return this.exceedsMaxSize
|| (this.nbrDuplicatedFiles === this.files.length)
|| (this.getFailedFiles().length === this.files.length);
},
totalSize() {
let files = this.finishIncomplete ? this.failedFiles : this.files;
Expand Down Expand Up @@ -588,6 +592,7 @@ export default {
this.availableQuotaBytes = biigle.$require('user-storage.availableQuota');
this.maxFilesizeBytes = biigle.$require('user-storage.maxFilesize');
this.chunkSize = biigle.$require('user-storage.chunkSize');
this.usedQuota = biigle.$require('user-storage.usedQuota')
// This remains null if no previous request exists.
this.storageRequest = biigle.$require('user-storage.previousRequest');
if (this.storageRequest && this.storageRequest.files.length > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/resources/views/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
biigle.$declare('user-storage.availableQuota', {!! $availableQuota !!});
biigle.$declare('user-storage.maxFilesize', {!! $maxFilesize !!});
biigle.$declare('user-storage.chunkSize', {!! $chunkSize !!});
biigle.$declare('user-storage.usedQuota', {!! $usedQuota !!});
</script>
@endpush

Expand Down

0 comments on commit 64ee390

Please sign in to comment.