Zachary Kotlarek 14 лет назад
Родитель
Сommit
7e535e26a4
1 измененных файлов с 2 добавлено и 7 удалено
  1. 2 7
      dmx/rope.pl

+ 2 - 7
dmx/rope.pl

@@ -126,15 +126,10 @@ while (1) {
 		$valueLast = $DIM{$state}{'value'};
 		$valueLast = $DIM{$state}{'value'};
 
 
 		# Save the state and value to disk
 		# Save the state and value to disk
-		my $fh;
-		open($fh, '>', $DATA_DIR . '/ROPE')
-		  or die("Unable to open ROPE");
+		my ($fh, $tmp) = tempfile($DATA_DIR . '/ROPE.XXXXXXXX', 'UNLINK' => 0);
 		print $fh 'State: ' . $state . "\nValue: " . $valueLast . "\n";
 		print $fh 'State: ' . $state . "\nValue: " . $valueLast . "\n";
 		close($fh);
 		close($fh);
-		open($fh, '>', $DATA_DIR . '/ROPE.lastUpdate')
-		  or die("Unable to open ROPE");
-		print $fh time() . "\n";
-		close($fh);
+		rename($tmp, $DATA_DIR . '/ROPE');
 	}
 	}
 
 
 	# Wait and loop
 	# Wait and loop