Update arguments passed to upload script.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Wed, 9 Apr 2008 21:04:44 +0000 (14:04 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Wed, 9 Apr 2008 21:04:44 +0000 (14:04 -0700)
Fix the remote upload script implementation in lbs so that it matches the
conventions expected by the S3 sample script.

remote.cc
remote.h
scandir.cc
store.cc

index a279751..6d80b02 100644 (file)
--- a/remote.cc
+++ b/remote.cc
@@ -67,13 +67,13 @@ RemoteStore::~RemoteStore()
  * will initially be created in a temporary directory.  When the file is
  * written out, the RemoteFile object should be passed to RemoteStore::enqueue,
  * which will upload it to the remote server. */
-RemoteFile *RemoteStore::alloc_file(const string &name)
+RemoteFile *RemoteStore::alloc_file(const string &name, const string &type)
 {
     fprintf(stderr, "Allocate file: %s\n", name.c_str());
     pthread_mutex_lock(&lock);
     files_outstanding++;
     pthread_mutex_unlock(&lock);
-    return new RemoteFile(this, name, staging_dir + "/" + name);
+    return new RemoteFile(this, name, type, staging_dir + "/" + name);
 }
 
 /* Request that a file be transferred to the remote server.  The actual
@@ -153,7 +153,8 @@ void RemoteStore::transfer_thread()
             }
             if (pid == 0) {
                 string cmd = backup_script;
-                cmd += " " + file->local_path + " " + file->remote_path;
+                cmd += " " + file->local_path + " " + file->type + " "
+                        + file->remote_path;
                 execlp("/bin/sh", "/bin/sh", "-c", cmd.c_str(), NULL);
                 throw IOException("exec failed");
             }
@@ -177,9 +178,11 @@ void RemoteStore::transfer_thread()
 }
 
 RemoteFile::RemoteFile(RemoteStore *remote,
-                       const string &name, const string &local_path)
+                       const string &name, const string &type,
+                       const string &local_path)
 {
     remote_store = remote;
+    this->type = type;
     this->local_path = local_path;
     this->remote_path = name;
 
index 85de06c..7c084c7 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -26,7 +26,7 @@ public:
     ~RemoteStore();
     void set_script(const std::string &script)
         { backup_script = script; }
-    RemoteFile *alloc_file(const std::string &name);
+    RemoteFile *alloc_file(const std::string &name, const std::string &type);
     void enqueue(RemoteFile *file);
     void sync();
 
@@ -65,12 +65,13 @@ private:
     friend class RemoteStore;
 
     RemoteFile(RemoteStore *remote,
-               const std::string &name, const std::string &local_path);
+               const std::string &name, const std::string &type,
+               const std::string &local_path);
 
     RemoteStore *remote_store;
 
     int fd;
-    std::string local_path;
+    std::string type, local_path;
     std::string remote_path;
 };
 
index 1daf352..eb05243 100644 (file)
@@ -782,7 +782,8 @@ int main(int argc, char *argv[])
     if (backup_scheme.size() > 0)
         checksum_filename += backup_scheme + "-";
     checksum_filename = checksum_filename + desc_buf + "." + csum_type + "sums";
-    RemoteFile *checksum_file = remote->alloc_file(checksum_filename);
+    RemoteFile *checksum_file = remote->alloc_file(checksum_filename,
+                                                   "checksums");
     FILE *checksums = fdopen(checksum_file->get_fd(), "w");
 
     for (std::set<string>::iterator i = segment_list.begin();
@@ -824,7 +825,8 @@ int main(int argc, char *argv[])
         desc_filename += backup_scheme + "-";
     desc_filename = desc_filename + desc_buf + ".lbs";
 
-    RemoteFile *descriptor_file = remote->alloc_file(desc_filename);
+    RemoteFile *descriptor_file = remote->alloc_file(desc_filename,
+                                                     "snapshots");
     int descriptor_fd = descriptor_file->get_fd();
     if (descriptor_fd < 0) {
         fprintf(stderr, "Unable to open descriptor output file: %m\n");
index 3dcfcb4..f4f1dbb 100644 (file)
--- a/store.cc
+++ b/store.cc
@@ -229,7 +229,7 @@ ObjectReference TarSegmentStore::write_object(const char *data, size_t len,
         segment->basename += filter_extension;
         segment->count = 0;
         segment->size = 0;
-        segment->rf = remote->alloc_file(segment->basename);
+        segment->rf = remote->alloc_file(segment->basename, "segments");
         segment->file = new Tarfile(segment->rf, segment->name);
 
         segments[group] = segment;