diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-09-19 03:40:32 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-09-19 03:40:32 +0000 |
commit | f2c05c63f98d2cc4f30dc23ad59819e53e405116 (patch) | |
tree | 469fe5a1e2098ff761e042f10571a4d685f8cee4 | |
parent | 804b313a85780a0c3403cea5caae7bb6977352ec (diff) | |
download | brdo-f2c05c63f98d2cc4f30dc23ad59819e53e405116.tar.gz brdo-f2c05c63f98d2cc4f30dc23ad59819e53e405116.tar.bz2 |
#197266 by ufku, lilou, Dave Reid, and c960657: Avoid unnecessary query if there is no user limit on uploaded files.
-rw-r--r-- | includes/file.inc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/includes/file.inc b/includes/file.inc index 7696163b0..7770b9244 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -733,7 +733,7 @@ function file_validate_extensions($file, $extensions) { * @param $file_limit * An integer specifying the maximum file size in bytes. Zero indicates that * no limit should be enforced. - * @param $$user_limit + * @param $user_limit * An integer specifying the maximum number of bytes the user is allowed. * Zero indicates that no limit should be enforced. * @return @@ -751,8 +751,7 @@ function file_validate_size($file, $file_limit = 0, $user_limit = 0) { $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit))); } - $total_size = file_space_used($user->uid) + $file->filesize; - if ($user_limit && $total_size > $user_limit) { + if ($user_limit && (file_space_used($user->uid) + $file->filesize) > $user_limit) { $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit))); } } |