Parcourir la source

More carefully reset data when files become unavailable

Zachary Kotlarek il y a 13 ans
Parent
commit
8f6c942a4f
1 fichiers modifiés avec 15 ajouts et 6 suppressions
  1. 15 6
      dmx/state.pl

+ 15 - 6
dmx/state.pl

@@ -234,12 +234,25 @@ while (1) {
 			next;
 			next;
 		}
 		}
 
 
+		# Always record the previous status and clear the new one
+		$file->{'last'}   = $file->{'status'};
+		$file->{'status'} = 0;
+
 		# Track available/unavailable files
 		# Track available/unavailable files
 		{
 		{
 			my $wasAvailable = $file->{'available'};
 			my $wasAvailable = $file->{'available'};
 			$file->{'available'} = -r $file->{'path'} ? 1 : 0;
 			$file->{'available'} = -r $file->{'path'} ? 1 : 0;
 			if ($wasAvailable != $file->{'available'}) {
 			if ($wasAvailable != $file->{'available'}) {
 
 
+				# Reset and extras for this file
+				if (exists($EXTRAS{ $file->{'name'} })) {
+					foreach my $extra (keys(%{ $EXTRAS{ $file->{'name'} } })) {
+						my $name = $file->{'name'} . '_' . $extra;
+						$files{$name}{'last'}   = $files{$name}{'status'};
+						$files{$name}{'status'} = 0;
+					}
+				}
+
 				# Determine which display device we have (if any)
 				# Determine which display device we have (if any)
 				if (exists($DISPLAY_DEVS{ $file->{'name'} })) {
 				if (exists($DISPLAY_DEVS{ $file->{'name'} })) {
 					$DISPLAY = $file->{'name'};
 					$DISPLAY = $file->{'name'};
@@ -261,10 +274,6 @@ while (1) {
 			next;
 			next;
 		}
 		}
 
 
-		# Always record the previous status and clear the new one
-		$file->{'last'}   = $file->{'status'};
-		$file->{'status'} = 0;
-
 		# Record the last update for STATUS and MTIME files
 		# Record the last update for STATUS and MTIME files
 		if ($file->{'type'} =~ /^STATUS/ || $file->{'type'} =~ /^MTIME/) {
 		if ($file->{'type'} =~ /^STATUS/ || $file->{'type'} =~ /^MTIME/) {
 			$file->{'update'} = mtime($file->{'path'});
 			$file->{'update'} = mtime($file->{'path'});
@@ -308,12 +317,12 @@ while (1) {
 			}
 			}
 
 
 			# Handle extras, if any
 			# Handle extras, if any
-			if ($EXTRAS{ $file->{'name'} }) {
+			if (exists($EXTRAS{ $file->{'name'} })) {
 				foreach my $extra (keys(%{ $EXTRAS{ $file->{'name'} } })) {
 				foreach my $extra (keys(%{ $EXTRAS{ $file->{'name'} } })) {
 
 
 					my $name = $file->{'name'} . '_' . $extra;
 					my $name = $file->{'name'} . '_' . $extra;
 					$files{$name}{'last'}   = $files{$name}{'status'};
 					$files{$name}{'last'}   = $files{$name}{'status'};
-					$files{$name}{'status'} = '';
+					$files{$name}{'status'} = 0;
 					$files{$name}{'update'} = $file->{'update'};
 					$files{$name}{'update'} = $file->{'update'};
 
 
 					if ($text =~ $EXTRAS{ $file->{'name'} }{$extra}) {
 					if ($text =~ $EXTRAS{ $file->{'name'} }{$extra}) {