Index: trunk/DataStore/scripts/dsget
===================================================================
--- trunk/DataStore/scripts/dsget	(revision 16301)
+++ trunk/DataStore/scripts/dsget	(revision 16342)
@@ -3,5 +3,5 @@
 # Copyright (C) 2006-2008  Joshua Hoblitt
 #
-# $Id: dsget,v 1.12 2008-02-05 04:57:10 eugene Exp $
+# $Id: dsget,v 1.13 2008-02-06 23:48:13 eugene Exp $
 
 use strict;
@@ -51,11 +51,4 @@
 } 
 
-# if ($uriVolume) {
-#     print "uriVolume: $uriVolume\n";
-# }
-# if ($uriFilename) {
-#     print "uriFilename: $uriFilename\n";
-# }
-
 if ($volume and $uriVolume and ($volume ne $uriVolume)) {
     die "conflicting volume names specified";
@@ -65,13 +58,8 @@
 if ($uriFilename) { $filename = $uriFilename; }
 
-# if ($volume) {
-#     print "volume: $volume\n";
-# } else {
-#     print "volume undefined\n";
-# }
-# print "filename: $filename\n";
-# if ($nebulous) {
-#     print "using nebulous\n";
-# }
+# XXX EAM : should not need parse_neb_key, but how to handle case
+# where we supply --volume and neb://volume/path ? 
+# 1) parse anyway and check for conflict
+# 2) drop --volume option
 
 my %p = (
@@ -83,36 +71,51 @@
 $p{md5sum} = $md5 if defined $md5;
 
-my $dirname = dirname($filename);
-
-if (!-d $dirname) {
+my $tmp;
+
+if (!$nebulous) {
+
     # create path and possibly fix up permissions
-    mkpath([$dirname], 1, 0775);
-}
-
-# can we truely write to filename?
-{
-    # open file for read/write but not create
-    my $fh;
-    if (open($fh, '+<', $filename)) {
-        # do nothing and fall through
-    } elsif (open($fh, '>>', $filename)) {
-        # this is the "stomp on it behavior" this probably shouldn't be the
-        # default and it may make sense to check the md5sum/bytes count of the
-        # files that's already in place to see if we really need to re-fetch it
-        unlink $filename or die "can't unlink $filename: $!";
-    } else {
-        die "can't write to $filename";
+    my $dirname = dirname($filename);
+    if (!-d $dirname) {
+	mkpath([$dirname], 1, 0775);
     }
-}
-
-my $tmp = File::Temp->new(
-    DIR         => $dirname,
-    TEMPLATE    => '.' . basename($filename) . '.XXXXXXXX',
-    SUFFIX      => '.tmp',
-    UNLINK      => 1,
-);
+
+    # can we truly write to filename?
+    {
+	# open file for read/write but not create
+	my $fh;
+	if (open($fh, '+<', $filename)) {
+	    # do nothing and fall through
+	} elsif (open($fh, '>>', $filename)) {
+	    # this is the "stomp on it behavior" this probably shouldn't be the
+	    # default and it may make sense to check the md5sum/bytes count of the
+	    # files that's already in place to see if we really need to re-fetch it
+	    unlink $filename or die "can't unlink $filename: $!";
+	} else {
+	    die "can't write to $filename";
+	}
+    }
+
+    # for non-neb files, use the download directory for the tmp file
+    $tmp = File::Temp->new(
+			   DIR         => $dirname,
+			   TEMPLATE    => '.' . basename($filename) . '.XXXXXXXX',
+			   SUFFIX      => '.tmp',
+			   UNLINK      => 1,
+			   );
+} else {
+    # for neb files, use /tmp for the tmp file
+    $tmp = File::Temp->new(
+			   DIR         => '/tmp',
+			   TEMPLATE    => basename($filename) . '.XXXXXXXX',
+			   SUFFIX      => '.tmp',
+			   UNLINK      => 1,
+			   );
+}
 
 my $tmpfilename = $tmp->filename;
-
+print "downloading file to $tmpfilename\n";
+
+# request the file from the remote data store server (save in tmpfilename)
 my $response = DataStore::File->new(%p)->request( filename => $tmpfilename );
 
