-/* Cumulus: Smart Filesystem Backup to Dumb Servers
- *
- * Copyright (C) 2006-2009 The Regents of the University of California
- * Copyright (C) 2012 Google Inc.
- * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+/* Cumulus: Efficient Filesystem Backup to the Cloud
+ * Copyright (C) 2006-2009, 2012 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
#include <vector>
#include "exclude.h"
+#include "hash.h"
#include "localdb.h"
#include "metadata.h"
#include "remote.h"
#include "store.h"
-#include "sha1.h"
#include "subfile.h"
#include "util.h"
+#include "third_party/sha1.h"
using std::list;
using std::map;
/* If the file is new or changed, we must read in the contents a block at a
* time. */
if (!cached) {
- SHA1Checksum hash;
+ Hash *hash = Hash::New();
Subfile subfile(db);
subfile.load_old_blocks(old_blocks);
break;
}
- hash.process(block_buf, bytes);
+ hash->update(block_buf, bytes);
// Sparse file processing: if we read a block of all zeroes, encode
// that explicitly.
status = "old";
}
- file_info["checksum"] = hash.checksum_str();
+ file_info["checksum"] = hash->digest_str();
+ delete hash;
}
// Sanity check: if we are rebuilding the statcache, but the file looks
* one block (1 MB) worth of data. If the file doesn't seems like it might
* be larger than that, don't parse the rules in it. */
ssize_t bytes = file_read(fd, block_buf, LBS_BLOCK_SIZE);
+ close(fd);
if (bytes < 0 || bytes >= static_cast<ssize_t>(LBS_BLOCK_SIZE - 1)) {
/* TODO: Add more strict resource limits on merge files? */
fprintf(stderr,
DIR *dir = opendir(path.c_str());
if (dir == NULL) {
- fprintf(stderr, "Error: %m\n");
+ fprintf(stderr, "Error reading directory %s: %m\n",
+ path.c_str());
return;
}
int main(int argc, char *argv[])
{
+ hash_init();
+
string backup_dest = "", backup_script = "";
string localdb_dir = "";
string backup_scheme = "";