diff options
author | Andy Staudacher <andy.st@gmail.com> | 2010-02-02 13:41:50 -0800 |
---|---|---|
committer | Andy Staudacher <andy.st@gmail.com> | 2010-02-02 13:41:50 -0800 |
commit | 31aaf7555f51dd80cf1e97fd3c20a1c245cbf61b (patch) | |
tree | 594ca1cebbe5b8b58b4c50cb3c88487574dba712 /modules/gallery/helpers/gallery_task.php | |
parent | be5f38adea89bdb95be359aea3d97615b6b530a3 (diff) | |
parent | 3c3671cff25f28e21a702b1f665a6baa282d045f (diff) |
Merge commit 'upstream/master'
Diffstat (limited to 'modules/gallery/helpers/gallery_task.php')
-rw-r--r-- | modules/gallery/helpers/gallery_task.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index c75e050a..3e6278e5 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -40,7 +40,7 @@ class gallery_task_Core { $tasks[] = Task_Definition::factory() ->callback("gallery_task::file_cleanup") ->name(t("Remove old files")) - ->description(t("Remove files from the logs and tmp directory")) + ->description(t("Remove expired files from the logs and tmp directory")) ->severity(log::SUCCESS); return $tasks; } @@ -111,6 +111,7 @@ class gallery_task_Core { site_status::clear("graphics_dirty"); } } catch (Exception $e) { + Kohana_Log::add("error",(string)$e); $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); @@ -214,6 +215,7 @@ class gallery_task_Core { Cache::instance()->delete("update_l10n_cache:{$task->id}"); } } catch (Exception $e) { + Kohana_Log::add("error",(string)$e); $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); @@ -233,13 +235,13 @@ class gallery_task_Core { try { $start = microtime(true); $data = Cache::instance()->get("file_cleanup_cache:{$task->id}"); - if ($data) { - $files = unserialize($data); - } + $files = $data ? unserialize($data) : array(); $i = 0; + $current = 0; + $total = 0; switch ($task->get("mode", "init")) { - case "init": // 0% + case "init": $threshold = time() - 1209600; // older than 2 weeks foreach(array("logs", "tmp") as $dir) { $dir = VARPATH . $dir; @@ -262,6 +264,7 @@ class gallery_task_Core { if (count($files) == 0) { break; } + case "delete_files": $current = $task->get("current"); $total = $task->get("total"); @@ -273,14 +276,17 @@ class gallery_task_Core { $task->set("current", $current); } - $task->status = t("Removed: %count files. Total: %total_count.", - array("count" => $current, "total_count" => $total)); + $task->status = t2("Removed: 1 file. Total: %total_count.", + "Removed: %count files. Total: %total_count.", + $current, array("total_count" => $total)); if ($total == $current) { $task->done = true; $task->state = "success"; + $task->percent_complete = 100; } } catch (Exception $e) { + Kohana_Log::add("error",(string)$e); $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); |