Index: trunk/DataStoreServer/scripts/dsreg
===================================================================
--- trunk/DataStoreServer/scripts/dsreg	(revision 26829)
+++ trunk/DataStoreServer/scripts/dsreg	(revision 27230)
@@ -356,9 +356,18 @@
                 die "file $path not found";
             }
-            if (!$file->{bytes}) {
-                my @finfo = stat($path);
-                unless (@finfo) {
-                    die ("can't stat $path");
+            # get the size of the file
+            my @finfo = stat($path);
+            unless (@finfo) {
+                die ("can't stat $path");
+            }
+            # if size was supplied make sure that it matches the actual
+            # size
+            if ($file->{bytes}) {
+                my $current_size = $finfo[7];
+                if ($file->{bytes} != $current_size) {
+                    die "size on disk: $current_size does not match supplied"
+                    . " size: $file->{bytes} for $path";
                 }
+            } else {
                 $file->{bytes}  = $finfo[7];
             }
