summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-11 21:33:34 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-11 21:33:34 +0000
commit73d24ff28e1561fb000edce42965b439bc04f53b (patch)
tree929454750af7ae2a48a80fac592afe12b3b39b25 /rdiff-backup/rdiff_backup
parentf6e83fa5b76594ab9dff64ee450087883c16b897 (diff)
downloadrdiff-backup-73d24ff28e1561fb000edce42965b439bc04f53b.tar.gz
Various final bug fixes for 0.7.4
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@79 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r--rdiff-backup/rdiff_backup/header.py2
-rw-r--r--rdiff-backup/rdiff_backup/increment.py63
-rw-r--r--rdiff-backup/rdiff_backup/restore.py2
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py4
4 files changed, 63 insertions, 8 deletions
diff --git a/rdiff-backup/rdiff_backup/header.py b/rdiff-backup/rdiff_backup/header.py
index 38d45c8..020a63f 100644
--- a/rdiff-backup/rdiff_backup/header.py
+++ b/rdiff-backup/rdiff_backup/header.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
# rdiff-backup -- Mirror files while keeping incremental changes
-# Version 0.7.3 released April 29, 2002
+# Version 0.7.4 released May 11, 2002
# Copyright (C) 2001, 2002 Ben Escoto <bescoto@stanford.edu>
#
# This program is licensed under the GNU General Public License (GPL).
diff --git a/rdiff-backup/rdiff_backup/increment.py b/rdiff-backup/rdiff_backup/increment.py
index b28b315..4e96e59 100644
--- a/rdiff-backup/rdiff_backup/increment.py
+++ b/rdiff-backup/rdiff_backup/increment.py
@@ -9,6 +9,12 @@ execfile("filename_mapping.py")
class Inc:
"""Class containing increment functions"""
+ # This is a hack. _inc_file holds the dsrp of the latest
+ # increment file created, to be used in IncrementITR for
+ # statistics purposes. It should be given directly to the ITR
+ # object but there didn't seem to be a good way to pass it out.
+ _inc_file = None
+
def Increment_action(new, mirror, incpref):
"""Main file incrementing function, returns RobustAction
@@ -95,7 +101,9 @@ class Inc:
while 1:
inctime = Resume.FindTime(rp.index, inctime)
incrp = get_newinc(Time.timetostring(inctime))
- if not incrp.lstat(): return incrp
+ if not incrp.lstat(): break
+ Inc._inc_file = incrp
+ return incrp
MakeStatic(Inc)
@@ -134,6 +142,7 @@ class IncrementITR(IterTreeReducer):
dsrp is the local file to be incremented
"""
+ self.init_statistics(diff_rorp, dsrp)
incpref = self.inc_rpath.new_index(index)
if Globals.quoting_enabled: incpref.quote_path()
if dsrp.isdir():
@@ -141,6 +150,26 @@ class IncrementITR(IterTreeReducer):
self.setvals(diff_rorp, dsrp, incpref)
else: self.init_non_dir(dsrp, diff_rorp, incpref)
+ def init_statistics(self, diff_rorp, dsrp):
+ """Set initial values for various statistics
+
+ These refer to the old mirror or to new increment files. Note
+ that changed_file_size could be bigger than total_file_size.
+ The other statistic, increment_file_size, is set later when we
+ have that information.
+
+ """
+ if dsrp.lstat():
+ self.total_files = 1
+ self.total_file_size = dsrp.getsize()
+ else: self.total_files = self.total_file_size = 0
+ if diff_rorp:
+ self.changed_files = 1
+ if dsrp.lstat(): self.changed_file_size = dsrp.getsize()
+ else: self.changed_file_size = 0
+ else: self.changed_files = self.changed_file_size = 0
+ self.increment_file_size = 0
+
def override_changed(self):
"""Set changed flag to true
@@ -195,6 +224,9 @@ class IncrementITR(IterTreeReducer):
Robust.chain([Inc.Increment_action(diff_rorp, dsrp, incpref),
RORPIter.patchonce_action(None, dsrp, diff_rorp)]
).execute()
+
+ self.increment_file_size += ((Inc._inc_file and Inc._inc_file.lstat()
+ and Inc._inc_file.getsize()) or 0)
self.changed = 1
def end_process(self):
@@ -213,9 +245,32 @@ class IncrementITR(IterTreeReducer):
if diff_rorp:
RORPIter.patchonce_action(None, dsrp, diff_rorp).execute()
+ self.increment_file_size += ((Inc._inc_file and Inc._inc_file.lstat()
+ and Inc._inc_file.getsize()) or 0)
+ self.write_statistics()
+
+ def write_statistics(self):
+ """Write the accumulated totals into file in inc directory"""
+ if not self.incpref.isdir(): return # only write for directories
+ statrp = Inc.get_inc_ext(self.incpref.append("directory_statistics"),
+ "data")
+ tf = TempFileManager.new(statrp)
+ def init_thunk():
+ fp = tf.open("w")
+ fp.write("TotalFiles %d\n" % self.total_files)
+ fp.write("TotalFileSize %d\n" % self.total_file_size)
+ fp.write("ChangedFiles %d\n" % self.changed_files)
+ fp.write("ChangedFileSize %d\n" % self.changed_file_size)
+ fp.write("IncrementFileSize %d\n" % self.increment_file_size)
+ fp.close()
+ Robust.make_tf_robustaction(init_thunk, (tf,), (statrp,)).execute()
+
def branch_process(self, subinstance):
- """Update the has_changed flag if change in branch"""
+ """Update statistics, and the has_changed flag if change in branch"""
if subinstance.changed: self.changed = 1
-
-
+ self.total_files += subinstance.total_files
+ self.total_file_size += subinstance.total_file_size
+ self.changed_files += subinstance.changed_files
+ self.changed_file_size += subinstance.changed_file_size
+ self.increment_file_size += subinstance.increment_file_size
diff --git a/rdiff-backup/rdiff_backup/restore.py b/rdiff-backup/rdiff_backup/restore.py
index 0faa9b2..5026716 100644
--- a/rdiff-backup/rdiff_backup/restore.py
+++ b/rdiff-backup/rdiff_backup/restore.py
@@ -213,7 +213,7 @@ class Restore:
"""Add filename to the inc tuple dictionary"""
rp = rid.inc_rpath.append(filename)
if Globals.quoting_enabled: rp.quote_path()
- if rp.isincfile():
+ if rp.isincfile() and rp.getinctype() != 'data':
basename = rp.getincbase_str()
affirm_dict_indexed(basename)
rid_dict[basename].inc_list.append(rp)
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index 748cab4..5ed36f5 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -456,7 +456,6 @@ class RPath(RORPath):
if stat.S_ISREG(mode):
type = 'reg'
- data['size'] = statblock[stat.ST_SIZE]
elif stat.S_ISDIR(mode): type = 'dir'
elif stat.S_ISCHR(mode):
type = 'dev'
@@ -471,6 +470,7 @@ class RPath(RORPath):
elif stat.S_ISSOCK(mode): type = 'sock'
else: raise RPathException("Unknown type for %s" % self.path)
data['type'] = type
+ data['size'] = statblock[stat.ST_SIZE]
data['perms'] = stat.S_IMODE(mode)
data['uid'] = statblock[stat.ST_UID]
data['gid'] = statblock[stat.ST_GID]
@@ -754,7 +754,7 @@ class RPath(RORPath):
if type == 'c': datatype = 'chr'
elif type == 'b': datatype = 'blk'
else: raise RPathException
- self.data = {'type': datatype, 'devnums': (type, major, minor)}
+ self.setdata()
def getRORPath(self, include_contents = None):
"""Return read only version of self"""