As we're ramping up for calling dmedia "production ready", I've been thinking more on the constant verification dmedia will to do make sure the metadata reflects the reality on the hard drives.
FileStore.verify() is the only hard-and-true reality check possible... either the exact bits are there or not. However, full verification in time consuming so this puts a limit on how often we can do it.
So I'd like to balance this out with some "softer" reality checks that we can run far more often. The soft verification is to make sure the file exists, has the correct size, and has the expected time-stamp.
So I'm adding a rather strict FileStore.stat() method, and making FileStore.__iter__() much stricter plus having it yield `Stat` namedtuples instead of just the id. The `Stat` namedtuple has:
`id` - the file id
`size` - the file size in bytes
`mtime` - the modification time-stamp
This means list(FileStore) gives you a quick and rather through picture of what is contained in the file-store. For example, you can now get total combined size of all the files in a store like this:
>>> from filestore import FileStore
>>> store = FileStore('/media/A')
>>> sum(st.size for st in store)
338015276422
As we're ramping up for calling dmedia "production ready", I've been thinking more on the constant verification dmedia will to do make sure the metadata reflects the reality on the hard drives.
FileStore.verify() is the only hard-and-true reality check possible... either the exact bits are there or not. However, full verification in time consuming so this puts a limit on how often we can do it.
So I'd like to balance this out with some "softer" reality checks that we can run far more often. The soft verification is to make sure the file exists, has the correct size, and has the expected time-stamp.
So I'm adding a rather strict FileStore.stat() method, and making FileStore. __iter_ _() much stricter plus having it yield `Stat` namedtuples instead of just the id. The `Stat` namedtuple has:
`id` - the file id
`size` - the file size in bytes
`mtime` - the modification time-stamp
This means list(FileStore) gives you a quick and rather through picture of what is contained in the file-store. For example, you can now get total combined size of all the files in a store like this:
>>> from filestore import FileStore '/media/ A')
>>> store = FileStore(
>>> sum(st.size for st in store)
338015276422