summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-04-11 12:13:28 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-04-11 12:13:28 +0200
commitce6162603ec08565f9ef9ff406e321b4bae2f038 (patch)
tree8725fc92320b0cf19909615098efecfdbeceb17b /application/controllers/file.php
parentf953eba8d7c9e362fd18a311367a6fc7b9b9cac4 (diff)
Add filesize to history view
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index e5e984b21..b8b22f12b 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -127,7 +127,7 @@ class File extends CI_Controller {
if (! $cached = $this->memcachelibrary->get("history_".$this->var->view_dir."_".$user)) {
$query = array();
$lengths = array();
- $fields = array("id", "filename", "mimetype", "date", "hash");
+ $fields = array("id", "filename", "mimetype", "date", "hash", "filesize");
$this->data['title'] .= ' - Upload history';
foreach($fields as $length_key) {
$lengths[$length_key] = 0;
@@ -142,6 +142,7 @@ class File extends CI_Controller {
foreach($query as $key => $item) {
$query[$key]["date"] = date("r", $item["date"]);
+ $query[$key]["filesize"] = format_bytes($item["filesize"]);
if ($this->var->cli_client) {
// Keep track of longest string to pad plaintext output correctly
foreach($fields as $length_key) {
@@ -343,6 +344,36 @@ class File extends CI_Controller {
}
closedir($outer_dh);
}
+
+ function update_file_sizes()
+ {
+ if (!$this->input->is_cli_request()) return;
+
+ $chunk = 500;
+
+ $total = $this->db->count_all("files");
+
+ for ($limit = 0; $limit < $total; $limit += $chunk) {
+ $query = $this->db->query("
+ SELECT hash
+ FROM files
+ GROUP BY hash
+ LIMIT $limit, $chunk
+ ")->result_array();
+
+ foreach ($query as $key => $item) {
+ $hash = $item["hash"];
+ $filesize = intval(filesize($this->file_mod->file($hash)));
+ $this->db->query("
+ UPDATE files
+ SET filesize = ?
+ WHERE hash = ?
+ ", array($filesize, $hash));
+ }
+ }
+
+
+ }
}
# vim: set noet: