Просмотр исходного кода

Handle permissions errors less drastically.

Zachary Kotlarek 12 лет назад
Родитель
Сommit
8de992e3f9
2 измененных файлов с 15 добавлено и 11 удалено
  1. 3 2
      web/includes/episode.php
  2. 12 9
      web/includes/series.php

+ 3 - 2
web/includes/episode.php

@@ -7,9 +7,10 @@ function findEpisodes($series, $season) {
 	$retval = array();
 
 	$season_path = seasonPath($series, $season);
-	$dir = opendir($season_path);
+	$dir = @opendir($season_path);
 	if ($dir === FALSE) {
-		die('Unable to opendir(): ' . htmlspecialchars($season_path) . "\n");
+		echo 'Unable to opendir(): ' . htmlspecialchars($season_path) . "\n";
+		return false;
 	}
 	while (false !== ($episode = readdir($dir))) {
 

+ 12 - 9
web/includes/series.php

@@ -104,18 +104,21 @@ function readFlags($series) {
 	# Find the most recent mtime in the series directory
 	$flags['mtime'] = filemtime($path);
 	$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
-	foreach($objects as $name => $object) {
+	try {
+		foreach($objects as $name => $object) {
 
-		# Skip junk
-		if (isJunk($name)) {
-			continue;
-		}
+			# Skip junk
+			if (isJunk($name)) {
+				continue;
+			}
 
-		# Track the most recent mtime
-		$mtime = filemtime($name);
-		if ($mtime > $flags['mtime']) {
-			$flags['mtime'] = $mtime;
+			# Track the most recent mtime
+			$mtime = filemtime($name);
+			if ($mtime > $flags['mtime']) {
+				$flags['mtime'] = $mtime;
+			}
 		}
+	} catch (UnexpectedValueException $e) {
 	}
 
 	# Look for all the exists files