Skip to content

Commit

Permalink
MDL-78196 user: Fix files used space check
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed May 10, 2023
1 parent 176a323 commit d82f687
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions user/externallib.php
Expand Up @@ -1215,8 +1215,10 @@ public static function add_user_private_files($draftid) {
$maxbytes = USER_CAN_IGNORE_FILE_SIZE_LIMITS;
$maxareabytes = FILE_AREA_MAX_BYTES_UNLIMITED;
} else {
// Get current used space for this user.
$usedspace = file_get_user_used_space();
// Get current used space for this user (private files only).
$fileareainfo = file_get_file_area_info($context->id, 'user', 'private');
$usedspace = $fileareainfo['filesize_without_references'];

// Get the total size of the new files we want to add to private files.
$newfilesinfo = file_get_draft_area_info($params['draftid']);

Expand Down
3 changes: 2 additions & 1 deletion user/tests/externallib_test.php
Expand Up @@ -1056,7 +1056,8 @@ public function test_add_user_private_files_quota() {
core_user_external::add_user_private_files($draftid);

// Force the quota so we are sure it won't be space to add the new file.
$CFG->userquota = file_get_user_used_space() + 1;
$fileareainfo = file_get_file_area_info($contextid, 'user', 'private');
$CFG->userquota = $fileareainfo['filesize_without_references'] + 1;

// Generate a new draftitemid for the same testfile.
$draftfile = core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
Expand Down

0 comments on commit d82f687

Please sign in to comment.