summaryrefslogtreecommitdiffstats
path: root/application
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
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')
-rw-r--r--application/controllers/file.php2
-rw-r--r--application/models/mfile.php28
2 files changed, 17 insertions, 13 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 571a4272f..85cef5490 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -687,7 +687,7 @@ class File extends MY_Controller {
assert($item["user"] === $user);
$item["data_id"] = $item['hash']."-".$item['storage_id'];
$query[$key]["data_id"] = $item["data_id"];
- if (!$this->mfile->valid_id($item["id"])) {
+ if (!$this->mfile->valid_filedata($item)) {
unset($query[$key]);
continue;
}
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)