summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-08-09 21:13:34 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-08-09 21:13:34 +0200
commit76f8f4826e8fab2118ae1b8c39d67da398ca892d (patch)
tree45551c3e8b29d71259846daeadf69649e152a6b2 /application/models
parentfd9d3931f84debc7577a13f12121eb5159d7e701 (diff)
Improve performance of thumbnail history
- Use the filedata we already have in c/file->upload_history_thumbnails() rather than fetching it per id in m/mfile->valid_id - Construct the config array for s/f::valid_id only once and not for every validation. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models')
-rw-r--r--application/models/mfile.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/application/models/mfile.php b/application/models/mfile.php
index 32ec224f0..5139a2eee 100644
--- a/application/models/mfile.php
+++ b/application/models/mfile.php
@@ -9,10 +9,19 @@
class Mfile extends CI_Model {
+ private $upload_path;
+
function __construct()
{
parent::__construct();
$this->load->model("muser");
+
+ $this->upload_path = $this->config->item('upload_path');
+ $this->id_validation_config = array(
+ "upload_max_age" => $this->config->item("upload_max_age"),
+ "small_upload_size" => $this->config->item("small_upload_size"),
+ "sess_expiration" => $this->config->item("sess_expiration"),
+ );
}
// Returns an unused ID
@@ -85,7 +94,7 @@ class Mfile extends CI_Model {
// return the folder in which the file with $data_id is stored
function folder($data_id) {
- return $this->config->item('upload_path').'/'.substr($data_id, 0, 3);
+ return $this->upload_path.'/'.substr($data_id, 0, 3);
}
// Returns the full path to the file with $data_id
@@ -119,20 +128,15 @@ class Mfile extends CI_Model {
}
// remove old/invalid/broken IDs
- function valid_id($id)
+ public function valid_id($id)
{
$filedata = $this->get_filedata($id);
- if (!$filedata) {
- return false;
- }
-
- $config = array(
- "upload_max_age" => $this->config->item("upload_max_age"),
- "small_upload_size" => $this->config->item("small_upload_size"),
- "sess_expiration" => $this->config->item("sess_expiration"),
- );
+ return \service\files::valid_id($filedata, $this->id_validation_config, $this, time());
+ }
- return \service\files::valid_id($filedata, $config, $this, time());
+ public function valid_filedata($filedata)
+ {
+ return \service\files::valid_id($filedata, $this->id_validation_config, $this, time());
}
public function file_exists($file)