Back to index

obnam  1.1
Public Member Functions
obnamlib.metadata.Metadata Class Reference

List of all members.

Public Member Functions

def __init__
def isdir
def islink
def isfile
def __repr__
def __cmp__

Detailed Description

Represent metadata for a filesystem entry.

The metadata for a filesystem entry (file, directory, device, ...)
consists of its stat(2) result, plus ACL and xattr.

This class represents them as fields.

We do not store all stat(2) fields. Here's a commentary on all fields:

    field?          stored? why

    st_atime_sec    yes     mutt compares atime, mtime to see ifmsg is new
    st_atime_nsec   yes     mutt compares atime, mtime to see ifmsg is new
    st_blksize      no      no way to restore, not useful backed up
    st_blocks       yes     should restore create holes in file?
    st_ctime        no      no way to restore, not useful backed up
    st_dev          yes     used to restore hardlinks
    st_gid          yes     used to restore group ownership
    st_ino          yes     used to restore hardlinks
    st_mode         yes     used to restore permissions
    st_mtime_sec    yes     used to restore mtime
    st_mtime_nsec   yes     used to restore mtime
    st_nlink        yes     used to restore hardlinks
    st_rdev         no      no use (correct me if I'm wrong about this)
    st_size         yes     user needs it to see size of file in backup
    st_uid          yes     used to restored ownership

The field 'target' stores the target of a symlink.
Additionally, the fields 'groupname' and 'username' are stored. They
contain the textual names that correspond to st_gid and st_uid. When
restoring, the names will be preferred by default.

The 'md5' field optionally stores the whole-file checksum for the file.

The 'xattr' field optionally stores extended attributes encoded as
a binary blob.

Definition at line 37 of file

Constructor & Destructor Documentation

def obnamlib.metadata.Metadata.__init__ (   self,

Definition at line 79 of file

00080     def __init__(self, **kwargs):
00081         for field in metadata_fields:
00082             setattr(self, field, None)
00083         for field, value in kwargs.iteritems():
00084             setattr(self, field, value)

Member Function Documentation

def obnamlib.metadata.Metadata.__cmp__ (   self,

Definition at line 99 of file

00100     def __cmp__(self, other):
00101         for field in metadata_fields:
00102             ours = getattr(self, field)
00103             theirs = getattr(other, field)
00104             if ours == theirs:
00105                 continue
00106             if ours < theirs:
00107                 return -1
00108             if ours > theirs:
00109                 return +1
00110         return 0
00113 # Caching versions of username/groupname lookups.
00114 # These work on the assumption that the mappings from uid/gid do not
00115 # change during the runtime of the backup.

Definition at line 94 of file

00095     def __repr__(self): # pragma: no cover
00096         fields = ', '.join('%s=%s' % (k, getattr(self, k))
00097                            for k in metadata_fields)
00098         return 'Metadata(%s)' % fields

Definition at line 85 of file

00086     def isdir(self):
00087         return self.st_mode is not None and stat.S_ISDIR(self.st_mode)

Here is the caller graph for this function:

Definition at line 91 of file

00092     def isfile(self):
00093         return self.st_mode is not None and stat.S_ISREG(self.st_mode)

Definition at line 88 of file

00089     def islink(self):
00090         return self.st_mode is not None and stat.S_ISLNK(self.st_mode)

The documentation for this class was generated from the following file: