projects
/
cumulus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add code to rebuild_database.py to recompute segment metadata.
[cumulus.git]
/
ref.cc
diff --git
a/ref.cc
b/ref.cc
index
2f870a6
..
c5a7768
100644
(file)
--- a/
ref.cc
+++ b/
ref.cc
@@
-1,7
+1,6
@@
-/* Cumulus: Smart Filesystem Backup to Dumb Servers
- *
- * Copyright (C) 2007 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
@@
-25,6
+24,9
@@
#include <assert.h>
#include <stdio.h>
#include <assert.h>
#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
#include <uuid/uuid.h>
#include <string>
#include <uuid/uuid.h>
#include <string>
@@
-95,7
+97,9
@@
string ObjectReference::to_string() const
if (range_valid) {
char buf[64];
if (range_valid) {
char buf[64];
- if (range_start == 0) {
+ if (range_exact) {
+ sprintf(buf, "[=%zu]", range_length);
+ } else if (type == REF_ZERO) {
sprintf(buf, "[%zu]", range_length);
} else {
sprintf(buf, "[%zu+%zu]", range_start, range_length);
sprintf(buf, "[%zu]", range_length);
} else {
sprintf(buf, "[%zu+%zu]", range_start, range_length);
@@
-157,10
+161,16
@@
ObjectReference ObjectReference::parse(const std::string& str)
}
// Range
}
// Range
- bool have_range = false;
+ bool have_range = false
, range_exact = false
;
int64_t range1 = 0, range2 = 0;
if (*t == '[') {
t++;
int64_t range1 = 0, range2 = 0;
if (*t == '[') {
t++;
+
+ if (*t == '=') {
+ range_exact = true;
+ t++;
+ }
+
s = t;
while (*t >= '0' && *t <= '9')
t++;
s = t;
while (*t >= '0' && *t <= '9')
t++;
@@
-172,6
+182,8
@@
ObjectReference ObjectReference::parse(const std::string& str)
} else {
if (*t != '+')
return ObjectReference();
} else {
if (*t != '+')
return ObjectReference();
+ if (range_exact)
+ return ObjectReference();
string val(s, t - s);
range1 = atoll(val.c_str());
string val(s, t - s);
range1 = atoll(val.c_str());
@@
-206,7
+218,7
@@
ObjectReference ObjectReference::parse(const std::string& str)
ref.set_checksum(checksum);
if (have_range)
ref.set_checksum(checksum);
if (have_range)
- ref.set_range(range1, range2);
+ ref.set_range(range1, range2
, range_exact
);
return ref;
}
return ref;
}
@@
-236,6
+248,9
@@
bool ObjectReference::merge(ObjectReference ref)
if (!range_valid || !ref.range_valid)
return false;
if (!range_valid || !ref.range_valid)
return false;
+ if (range_exact || ref.range_exact)
+ return false;
+
if (range_start + range_length == ref.range_start) {
range_length += ref.range_length;
return true;
if (range_start + range_length == ref.range_start) {
range_length += ref.range_length;
return true;