bobmet820 / unraid-simplefeatures

Automatically exported from code.google.com/p/unraid-simplefeatures
0 stars 0 forks source link

Browsing contents of empty drives results in errors from Browse.php [PATCH] #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add newly formatted drive.
2. Press icon to view contents of drive

What is the expected output? What do you see instead?
See attached image

What version of the product are you using? On what operating system?
unRAID 5.0-rc11
SimpleFeatures 1.0.11

Please provide any additional information below.

Patch to fix issue with minimal impact to existing formatting:
--- Browse.php.orig 2013-02-19 19:15:06.000000000 -0500
+++ Browse.php  2013-02-19 19:16:50.000000000 -0500
@@ -22,7 +22,7 @@
   $i = 0;
   exec("stat -L -c'%F|%n|%s|%Y' $path", &$file);
   if ($show_disk) exec("/usr/local/sbin/stat_ino -l $path", &$disk);
-  else $disk = array_fill(0, count($file), '');
+  else if (!empty($file)) { $disk = array_fill(0, count($file), '');
   foreach ($file as $entry) {
     $attr = explode('|', $entry);
     $list[] = array(
@@ -55,7 +55,7 @@
       array_multisort($type,$opt, $indx,$opt,SORT_NUMERIC, $name,$opt, $list);
     else
      array_multisort($type,$opt, $indx,$opt, $name,$opt, $list);
-  }
+  } }
 // return sorted list
   return $list;
 }
@@ -175,6 +175,7 @@
 <?endif;?>
   </tr>
 <?$dirs=0; $files=0; $total=0;
+  if (!empty($list)):
   foreach ($list as $entry):
 ?>  <tr>
 <?  if ($entry['type']=='directory'):
@@ -199,6 +200,7 @@
   endif;?>
     </tr>
 <?endforeach;
+  endif;
   $objs = $dirs + $files;
   $objtext = ($objs == 1)? "1 object" : "{$objs} objects";
   $dirtext = ($dirs == 1)? "1 directory" : "{$dirs} directories";

Original issue reported on code.google.com by ggal...@gmail.com on 20 Feb 2013 at 1:11

Attachments: