FileStore.stat() + stricter FileStore.__iter__()

Bug #850559 reported by Jason Gerard DeRose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
FileStore
Fix Released
High
Jason Gerard DeRose

Bug Description

As we're ramping up for calling dmedia "production ready", I've been thinking more on the constant verification dmedia will do to 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 is 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

Related branches

description: updated
description: updated
Changed in filestore:
status: In Progress → Fix Committed
Changed in filestore:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.