~xubuntu-dev/ubuntu-cdimage/xubuntu-base

« back to all changes in this revision

Viewing changes to lib/cdimage/checksums.py

  • Committer: Colin Watson
  • Date: 2013-02-18 22:15:36 UTC
  • Revision ID: cjwatson@canonical.com-20130218221536-kmubu9uhy1yzhhnm
cdimage.checksums: Refresh checksums if either the mtime or the ctime of the file in question is newer than that of the checksums file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
            return hash_obj.hexdigest()
79
79
 
80
80
    def add(self, entry_name):
81
 
        if entry_name not in self.entries:
82
 
            entry_path = os.path.join(self.directory, entry_name)
 
81
        try:
 
82
            this_time = os.stat(self.path).st_mtime
 
83
        except OSError:
 
84
            this_time = None
 
85
        entry_path = os.path.join(self.directory, entry_name)
 
86
        try:
 
87
            entry_stat = os.stat(entry_path)
 
88
            entry_time = max(entry_stat.st_mtime, entry_stat.st_ctime)
 
89
        except OSError:
 
90
            entry_time = None
 
91
        if (entry_name not in self.entries or
 
92
            (this_time is not None and entry_time is not None and
 
93
             entry_time > this_time)):
83
94
            self.entries[entry_name] = self.checksum(entry_path)
84
95
 
85
96
    def remove(self, entry_name):