Przeglądaj źródła

Die on opendir() errors for monitored files. Attempt to mount the media share at launch (I may need to make mountMedia more tolerant of disconnected operation

Zachary Kotlarek 13 lat temu
rodzic
commit
9d9ed36a4d
1 zmienionych plików z 10 dodań i 6 usunięć
  1. 10 6
      dmx/state.pl

+ 10 - 6
dmx/state.pl

@@ -95,6 +95,7 @@ my $DATA_DIR     = DMX::dataDir();
 my $CMD_FILE     = 'STATE';
 my $CMD_FILE     = 'STATE';
 my $MAX_CMD_LEN  = 4096;
 my $MAX_CMD_LEN  = 4096;
 my $RESET_CMD    = $ENV{'HOME'} . '/bin/video/dmx/reset.sh';
 my $RESET_CMD    = $ENV{'HOME'} . '/bin/video/dmx/reset.sh';
+my $MEDIA_CMD    = $ENV{'HOME'} . '/bin/video/mountMedia';
 my $PUSH_TIMEOUT = 20;
 my $PUSH_TIMEOUT = 20;
 
 
 # Debug
 # Debug
@@ -193,6 +194,9 @@ foreach my $name (keys(%MON_FILES)) {
 	$files{$name} = \%file;
 	$files{$name} = \%file;
 }
 }
 
 
+# Try to mount the media share
+system($MEDIA_CMD);
+
 # Delete any existing input files, to ensure our state is reset
 # Delete any existing input files, to ensure our state is reset
 foreach my $file (values(%files)) {
 foreach my $file (values(%files)) {
 	if (-e $file->{'path'}) {
 	if (-e $file->{'path'}) {
@@ -260,13 +264,13 @@ while (1) {
 	foreach my $file (values(%files)) {
 	foreach my $file (values(%files)) {
 		if (!$folders{ $file->{'dir'} }) {
 		if (!$folders{ $file->{'dir'} }) {
 			my $dh = undef();
 			my $dh = undef();
-			if (opendir($dh, $file->{'dir'})) {
-				if ($DEBUG) {
-					print STDERR 'Refreshed folder: ' . $file->{'dir'} . "\n";
-				}
-				my @files = readdir($dh);
-				closedir($dh);
+			opendir($dh, $file->{'dir'})
+			  or die('Unable to open directory: ' . $file->{'dir'});
+			if ($DEBUG) {
+				print STDERR 'Refreshed folder: ' . $file->{'dir'} . "\n";
 			}
 			}
+			my @files = readdir($dh);
+			closedir($dh);
 			$folders{ $file->{'dir'} } = 1;
 			$folders{ $file->{'dir'} } = 1;
 		}
 		}
 	}
 	}