summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-02-16 23:53:58 -0500
committerBharat Mediratta <bharat@menalto.com>2013-02-16 23:53:58 -0500
commitcc45e2e33b07cd27a87300f5d239394a14569308 (patch)
tree874bf217675634692ac0a43e4641d58cc1abbf13 /modules
parent4203ecc0b3c482e7dd687d70aa326fe7ad9365b0 (diff)
parent87d20c63af02ae573853da2cb82d7323a56677b5 (diff)
Merge branch 'master' into jquery_190
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/helpers/gallery_event.php33
-rw-r--r--modules/gallery/helpers/gallery_task.php6
-rw-r--r--modules/gallery/views/admin_movies.html.php2
3 files changed, 40 insertions, 1 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 54c60296..26432ef5 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -36,6 +36,39 @@ class gallery_event_Core {
locales::set_request_locale();
}
+ static function gallery_shutdown() {
+ // Every 500th request, do a pass over var/logs and var/tmp and delete old files.
+ // Limit ourselves to deleting a single file so that we don't spend too much CPU
+ // time on it. As long as servers call this at least twice a day they'll eventually
+ // wind up with a clean var/logs directory because we only create 1 file a day there.
+ // var/tmp might be stickier because theoretically we could wind up spamming that
+ // dir with a lot of files. But let's start with this and refine as we go.
+ if (!(rand() % 500)) {
+ // Note that this code is roughly duplicated in gallery_event::gallery_shutdown
+ $threshold = time() - 1209600; // older than 2 weeks
+ foreach(array("logs", "tmp") as $dir) {
+ $dir = VARPATH . $dir;
+ if ($dh = opendir($dir)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file[0] == ".") {
+ continue;
+ }
+
+ // Ignore directories for now, but we should really address them in the long term.
+ if (is_dir("$dir/$file")) {
+ continue;
+ }
+
+ if (filemtime("$dir/$file") <= $threshold) {
+ unlink("$dir/$file");
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
static function user_deleted($user) {
$admin = identity::admin_user();
if (!empty($admin)) { // could be empty if there is not identity provider
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 856d2639..a79cb2d5 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -281,6 +281,7 @@ class gallery_task_Core {
switch ($task->get("mode", "init")) {
case "init":
$threshold = time() - 1209600; // older than 2 weeks
+ // Note that this code is roughly duplicated in gallery_event::gallery_shutdown
foreach(array("logs", "tmp") as $dir) {
$dir = VARPATH . $dir;
if ($dh = opendir($dir)) {
@@ -289,6 +290,11 @@ class gallery_task_Core {
continue;
}
+ // Ignore directories for now, but we should really address them in the long term.
+ if (is_dir("$dir/$file")) {
+ continue;
+ }
+
if (filemtime("$dir/$file") <= $threshold) {
$files[] = "$dir/$file";
}
diff --git a/modules/gallery/views/admin_movies.html.php b/modules/gallery/views/admin_movies.html.php
index e7810711..242a4349 100644
--- a/modules/gallery/views/admin_movies.html.php
+++ b/modules/gallery/views/admin_movies.html.php
@@ -8,7 +8,7 @@
<p>
<?= t("Although popular, FFmpeg is not installed on all Linux systems.") ?>
<?= t("To use FFmpeg without fully installing it, download a pre-compiled, <b>static build</b> of FFmpeg from one of the links <a href=\"%url\">here</a>.", array("url" => "http://ffmpeg.org/download.html")) ?>
- <?= t("Then, put the \"ffmpeg\" file in Gallery's \"bin\" directory (e.g. \"/gallery/bin\"), where Gallery will auto-detect it.") ?>
+ <?= t("Then, put the \"ffmpeg\" file in Gallery's \"bin\" directory (e.g. \"/gallery3/bin\"), where Gallery will auto-detect it.") ?>
</p>
<p>
<?= t("Movies will work without FFmpeg, but their thumbnails will be placeholders.") ?>