Commits

Michele Bini committed c24c8e5

Make updates of status.php atomic even in networked filesystems, as long as file renames are atomic.

Comments (0)

Files changed (1)

v1.9/function.php

 
 	// Save status.php file to the same directory the script was
 	// called from.
-	$fh = fopen('/var/lib/timekoin/status.php', 'w');
+        $fname = uniqid("/var/lib/timekoin/status.php.");
+	$fh = fopen($fname, 'w');
 
 	if($fh != FALSE)
 	{
 		{
 			if(fclose($fh) == TRUE)
 			{
-				return TRUE;
+                                return (rename($fname, "/var/lib/timekoin/status.php") == TRUE);
 			}
 		}
 	}