3 # Cumulus: Efficient Filesystem Backup to the Cloud
4 # Copyright (C) 2012 The Cumulus Developers
5 # See the AUTHORS file for a list of contributors.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # Print a dump containing file metadata and content digests for a specified
22 # file system tree. Used to compare file system trees when running tests.
36 metadata.append("mode=%o" % st.st_mode)
38 metadata.append("mtime=%d" % st.st_mtime)
39 if stat.S_ISREG(st.st_mode):
40 digest = hashlib.sha256()
44 buf = f.read(BUF_SIZE)
47 metadata.append("sha256=%s" % digest.hexdigest())
52 for (dirpath, dirnames, filenames) in os.walk(root):
54 files.append(stat_file(os.path.join(dirpath, d)))
56 files.append(stat_file(os.path.join(dirpath, f)))
60 if __name__ == "__main__":
66 for file in dump_tree("."):
67 print " ".join(map(str, file))