Skip to content

Commit

Permalink
Put caches in a folder per user.
Browse files Browse the repository at this point in the history
Fixes possible album name conflicts.
  • Loading branch information
sofar committed Oct 13, 2012
1 parent fdf7c64 commit e9a6e3e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 0 additions & 2 deletions TODO
@@ -1,8 +1,6 @@

- Refine installation instructions a bit with examples and cmdlines

- make a cache folder per user: $cache_base/$user/$album/$object

- check input size against allowed list

- use ffmpeg to get "Date Created" from video files in bg daemon. Somehow
Expand Down
14 changes: 7 additions & 7 deletions album-watch.php
Expand Up @@ -27,11 +27,13 @@ function do_file($path, $album, $user)
}

# might need to mkdir first
if (!is_dir($cache_base . "/" . $album))
mkdir($cache_base . "/" . $album);
if (!is_dir($cache_base . "/" . $user))
mkdir($cache_base . "/" . $user);
if (!is_dir($cache_base . "/" . $user . "/" . $album))
mkdir($cache_base . "/" . $user . "/" . $album);

# thumbnail
$t = $cache_base . "/" . $album . "/" . $i['filename'] . ".thm";
$t = $cache_base . "/" . $user . "/" . $album . "/" . $i['filename'] . ".thm";
if (!is_file($t)) {
echo 'ffmpeg -i "' . $path . '" -ss 0 -vframes 1 -f mjpeg -an "' . $t . '.in"' . "\n";
system('ffmpeg -i "' . $path . '" -ss 0 -vframes 1 -f mjpeg -an "' . $t . '.in" > /dev/null 2>&1');
Expand Down Expand Up @@ -61,7 +63,7 @@ function do_file($path, $album, $user)
}

# mp4
$t = $cache_base . "/" . $album . "/" . $i['filename'] . ".mp4";
$t = $cache_base . "/" . $user . "/" . $album . "/" . $i['filename'] . ".mp4";
if (!is_file($t)) {
# most of my stuff is in AVI or MP4 format, and doesn't need any tuning to come out OK
# with mp4 format recoding
Expand All @@ -70,7 +72,7 @@ function do_file($path, $album, $user)
}

# ogv
$t = $cache_base . "/" . $album . "/" . $i['filename'] . ".ogv";
$t = $cache_base . "/" . $user . "/" . $album . "/" . $i['filename'] . ".ogv";
if (!is_file($t)) {
# with -sameq or no params, OGV's come out very pixelated and small. Instead
# code these at -qscale 6, which is small but plenty res for the web.
Expand Down Expand Up @@ -135,8 +137,6 @@ function do_file($path, $album, $user)
continue;
}

$cd = $cache_base . "/" . $album;

$ih = opendir($d . "/" . $album);
$image = readdir($ih);
while ($image) {
Expand Down
7 changes: 4 additions & 3 deletions db.php
Expand Up @@ -59,7 +59,7 @@
unset($date);
unset($albumdate);

$cd = $cache_base . "/" . $album;
$cd = $cache_base . "/" . $users[$x] . "/" . $album;
$ca = $cd . "/" . "db.js";

# cache intercept
Expand Down Expand Up @@ -168,9 +168,10 @@
echo $a;

# write cache entry
if (!is_dir($cd)) {
if (!is_dir($cache_base . "/" . $users[$x]))
mkdir($cache_base . "/" . $users[$x]);
if (!is_dir($cd))
mkdir($cd);
}

$fp = fopen($ca, "w");
if ($fp) {
Expand Down
2 changes: 1 addition & 1 deletion image.php
Expand Up @@ -134,7 +134,7 @@ function pass_file_and_exit($file) {
#header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);

$cache_path = $cache_base . "/" . $album;
$cache_path = $cache_base . "/" . $user . "/" . $album;

if (!is_dir($cache_path))
mkdir($cache_path);
Expand Down

0 comments on commit e9a6e3e

Please sign in to comment.