Index: trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 17694)
+++ trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 17716)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004-2008  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.71 2008-05-15 03:27:28 jhoblitt Exp $
+# $Id: Server.pm,v 1.72 2008-05-16 20:22:29 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -9,5 +9,5 @@
 no warnings qw( uninitialized );
 
-our $VERSION = '0.10';
+our $VERSION = '0.11';
 
 use base qw( Class::Accessor::Fast );
@@ -937,5 +937,5 @@
             unless ($rows > 0) {
                 $query->finish;
-                $log->logdie("no instances on storage volume: $vol_name or volume is not available");
+                $log->logdie("no instances on storage volume or volume is not avaiable for key: $key volume: $vol_name");
             }
         } else {
@@ -945,5 +945,5 @@
             unless ($rows > 0) {
                 $query->finish;
-                $log->logdie("no instances available");
+                $log->logdie("no instances available for key: $key");
             }
         }
@@ -1295,9 +1295,16 @@
         unless (open($fh, '>', $path));
 
+    # chmod before fsync() to make sure the changed perms hit the disk too
+    die "can not chmod $path: $!"
+        unless (chmod 0664, $path);
+
+    die "can not flush $path: $!"
+        unless ($fh->flush);
+
+    die "can not sync $path: $!"
+        unless ($fh->sync);
+
     die "can not close $path: $!"
         unless (close($fh));
-
-    die "can not chmod $path: $!"
-        unless (chmod 0664, $path);
 
     return $path;
