* 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
}
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");
}
}
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;
~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();
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;
};
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();
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");
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;