From bb96f44861c66e9eb334e18e4b4b659685433008 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 28 Apr 2016 21:02:27 -0700 Subject: allow engineering units (e.g. 400M, 1G) as service class limits --- Zotlabs/Storage/Browser.php | 2 +- Zotlabs/Storage/Directory.php | 6 +++--- Zotlabs/Storage/File.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 720940953..c75ebe41f 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -273,7 +273,7 @@ class Browser extends DAV\Browser\Plugin { return; // Storage and quota for the account (all channels of the owner of this directory)! - $limit = service_class_fetch($owner, 'attach_upload_limit'); + $limit = engr_units_to_bytes(service_class_fetch($owner, 'attach_upload_limit')); $r = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d", intval($this->auth->channel_account_id) ); diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index edbef5a95..3c0cff6ef 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -315,13 +315,13 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { } // check against service class quota - $limit = service_class_fetch($c[0]['channel_id'], 'attach_upload_limit'); + $limit = engr_units_to_bytes(service_class_fetch($c[0]['channel_id'], 'attach_upload_limit')); if ($limit !== false) { $x = q("SELECT SUM(filesize) AS total FROM attach WHERE aid = %d ", intval($c[0]['channel_account_id']) ); if (($x) && ($x[0]['total'] + $size > $limit)) { - logger('service class limit exceeded for ' . $c[0]['channel_name'] . ' total usage is ' . $x[0]['total'] . ' limit is ' . $limit); + logger('service class limit exceeded for ' . $c[0]['channel_name'] . ' total usage is ' . $x[0]['total'] . ' limit is ' . userReadableSize($limit)); attach_delete($c[0]['channel_id'], $hash); return; } @@ -549,7 +549,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { intval($this->auth->owner_id) ); - $ulimit = service_class_fetch($c[0]['channel_id'], 'attach_upload_limit'); + $ulimit = engr_units_to_bytes(service_class_fetch($c[0]['channel_id'], 'attach_upload_limit')); $limit = (($ulimit) ? $ulimit : $limit); $x = q("select sum(filesize) as total from attach where aid = %d", diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 897f24edd..d40fee0ea 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -208,13 +208,13 @@ class File extends DAV\Node implements DAV\IFile { return; } - $limit = service_class_fetch($c[0]['channel_id'], 'attach_upload_limit'); + $limit = engr_units_to_bytes(service_class_fetch($c[0]['channel_id'], 'attach_upload_limit')); if ($limit !== false) { $x = q("select sum(filesize) as total from attach where aid = %d ", intval($c[0]['channel_account_id']) ); if (($x) && ($x[0]['total'] + $size > $limit)) { - logger('service class limit exceeded for ' . $c[0]['channel_name'] . ' total usage is ' . $x[0]['total'] . ' limit is ' . $limit); + logger('service class limit exceeded for ' . $c[0]['channel_name'] . ' total usage is ' . $x[0]['total'] . ' limit is ' . userReadableSize($limit)); attach_delete($c[0]['channel_id'], $this->data['hash']); return; } -- cgit v1.2.3