diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-07-09 14:03:07 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-07-09 14:03:07 -0700 |
commit | 6fbb1e2dafdaa51c1a8fd5479819ff787c758c59 (patch) | |
tree | 616ab53d67eb30ce6070001cf1b2d7dccccbd620 /modules/server_add/controllers/server_add.php | |
parent | fad6c4783ebec8591e1b61bddcc7bd5f17d8cf0e (diff) |
Avoid blowing the task data column by only adding directories to the queue instead of directories and files.
Diffstat (limited to 'modules/server_add/controllers/server_add.php')
-rw-r--r-- | modules/server_add/controllers/server_add.php | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 638a4d63..cf7077a8 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -131,14 +131,21 @@ class Server_Add_Controller extends Admin_Controller { $queue = $task->get("queue"); while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $file; - $entry->save(); - if (is_dir($file)) { - $queue = array_merge( - $queue, empty($selections[$file]) ? glob("$file/*") : $selections[$file]); + $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; + } else { + $children = array($file); + } + + foreach ($children as $child) { + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $child; + $entry->save(); + + if (is_dir($child)) { + $queue[] = $child; + } } } // We have no idea how long this can take because we have no idea how deep the tree @@ -218,7 +225,7 @@ class Server_Add_Controller extends Admin_Controller { $entry->delete(); } $task->set("completed_files", $completed_files); - $task->status = t("Adding photos (%completed of %total)", + $task->status = t("Adding photos and albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files)); $task->percent_complete = 10 + 100 * ($completed_files / $total_files); |