projects
/
cumulus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Byte/string handling fixes for Python 3.
[cumulus.git]
/
metadata.cc
diff --git
a/metadata.cc
b/metadata.cc
index
f29c486
..
63fdadc
100644
(file)
--- a/
metadata.cc
+++ b/
metadata.cc
@@
-1,7
+1,6
@@
-/* Cumulus: Smart Filesystem Backup to Dumb Servers
- *
- * Copyright (C) 2007-2008 The Regents of the University of California
- * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+/* Cumulus: Efficient Filesystem Backup to the Cloud
+ * Copyright (C) 2007-2008 The Cumulus Developers
+ * See the AUTHORS file for a list of contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-24,6
+23,8
@@
* handling of the statcache, and re-use of metadata between snapshots.
*/
* handling of the statcache, and re-use of metadata between snapshots.
*/
+#include <stdlib.h>
+#include <string.h>
#include <string>
#include <iostream>
#include <map>
#include <string>
#include <iostream>
#include <map>
@@
-48,7
+49,6
@@
bool flag_full_metadata = false;
/* TODO: Move to header file */
extern LocalDb *db;
/* TODO: Move to header file */
extern LocalDb *db;
-void add_segment(const string& segment);
/* Like strcmp, but sorts in the order that files will be visited in the
* filesystem. That is, we break paths apart at slashes, and compare path
/* Like strcmp, but sorts in the order that files will be visited in the
* filesystem. That is, we break paths apart at slashes, and compare path
@@
-96,7
+96,7
@@
static string encode_dict(const map<string, string>& dict)
string result;
if (dict.find("name") != dict.end()) {
string result;
if (dict.find("name") != dict.end()) {
- result += "name: " + dict.
at("name")
+ "\n";
+ result += "name: " + dict.
find("name")->second
+ "\n";
}
for (map<string, string>::const_iterator i = dict.begin();
}
for (map<string, string>::const_iterator i = dict.begin();
@@
-116,7
+116,7
@@
MetadataWriter::MetadataWriter(TarSegmentStore *store,
{
statcache_path = path;
statcache_path += "/statcache2";
{
statcache_path = path;
statcache_path += "/statcache2";
- if (snapshot_scheme != NULL)
+ if (snapshot_scheme != NULL
&& strlen(snapshot_scheme) > 0
)
statcache_path = statcache_path + "-" + snapshot_scheme;
statcache_tmp_path = statcache_path + "." + snapshot_name;
statcache_path = statcache_path + "-" + snapshot_scheme;
statcache_tmp_path = statcache_path + "." + snapshot_name;
@@
-126,7
+126,7
@@
MetadataWriter::MetadataWriter(TarSegmentStore *store,
if (statcache_out == NULL) {
fprintf(stderr, "Error opening statcache %s: %m\n",
statcache_tmp_path.c_str());
if (statcache_out == NULL) {
fprintf(stderr, "Error opening statcache %s: %m\n",
statcache_tmp_path.c_str());
-
throw IOException
("Error opening statcache");
+
fatal
("Error opening statcache");
}
old_metadata_eof = false;
}
old_metadata_eof = false;
@@
-295,8
+295,7
@@
void MetadataWriter::metadata_flush()
// If indirectly referencing any other metadata logs, be sure those
// segments are properly referenced.
if (i->reused) {
// If indirectly referencing any other metadata logs, be sure those
// segments are properly referenced.
if (i->reused) {
- add_segment(i->ref.get_segment());
- db->UseSegment(i->ref.get_segment(), 1.0);
+ db->UseObject(i->ref);
}
// Write out an indirect reference to any previous objects which could
}
// Write out an indirect reference to any previous objects which could
@@
-337,15
+336,13
@@
void MetadataWriter::metadata_flush()
/* Write current metadata information to a new object. */
LbsObject *meta = new LbsObject;
meta->set_group("metadata");
/* Write current metadata information to a new object. */
LbsObject *meta = new LbsObject;
meta->set_group("metadata");
- meta->set_data(m.data(), m.size());
+ meta->set_data(m.data(), m.size()
, NULL
);
meta->write(store);
meta->write(store);
- meta->checksum();
/* Write a reference to this block in the root. */
ObjectReference ref = meta->get_ref();
metadata_root << "@" << ref.to_string() << "\n";
/* Write a reference to this block in the root. */
ObjectReference ref = meta->get_ref();
metadata_root << "@" << ref.to_string() << "\n";
- add_segment(ref.get_segment());
- db->UseSegment(ref.get_segment(), 1.0);
+ db->UseObject(ref);
delete meta;
delete meta;
@@
-376,7
+373,7
@@
void MetadataWriter::add(dictionary info)
if (info == old_metadata && !flag_full_metadata) {
ObjectReference ref = ObjectReference::parse(old_metadata_loc);
if (info == old_metadata && !flag_full_metadata) {
ObjectReference ref = ObjectReference::parse(old_metadata_loc);
- if (!ref.is_null()) {
+ if (!ref.is_null()
&& db->IsAvailable(ref)
) {
item.reused = true;
item.ref = ref;
}
item.reused = true;
item.ref = ref;
}
@@
-396,11
+393,9
@@
ObjectReference MetadataWriter::close()
LbsObject *root = new LbsObject;
root->set_group("metadata");
LbsObject *root = new LbsObject;
root->set_group("metadata");
- root->set_data(root_data.data(), root_data.size());
+ root->set_data(root_data.data(), root_data.size()
, NULL
);
root->write(store);
root->write(store);
- root->checksum();
- add_segment(root->get_ref().get_segment());
- db->UseSegment(root->get_ref().get_segment(), 1.0);
+ db->UseObject(root->get_ref());
ObjectReference ref = root->get_ref();
delete root;
ObjectReference ref = root->get_ref();
delete root;