Require explicit FileStore creation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
FileStore |
Fix Released
|
High
|
Jason Gerard DeRose |
Bug Description
So the time has come to make the V1 protocol the default, and to add the needed V0 => V1 migration functionality.
As this is a disruptive change that will need to land at the same time as the equivalent change in Dmedia, I've given some thought to other breaking API change we might want to do.
And there is one thing: over time, I've really come to regret the "implicit" FileStore creation that I originally implemented way before filestore was split out of Dmedia. For example, say you have an empty directory /tmp/foo, currently this works:
>>> fs = FileStore(
And it will implicitly create the /tmp/foo/.dmedia directory and the FileStore layout within. This turned out the be a bad idea. It's far better for code to either 1) assume the FileStore already exists, or 2) assume the FileStore needs to be created. But don't mix the two.
Err, I lied... there is actually another thing, closely related. Overall, I tried to keep filestore and Dmedia cleanly separated, and for filestore to be unaware of Dmedia schema decisions. So previously I had Dmedia create the dmedia/store doc in CouchDB, and then to provide the _id and copies to the FileStore constructor:
FileStore.
But this doesn't work well in a world where a FileStore is never implicitly created. It's much cleaner and simpler to have the presence of the .dmedia/store.json file indicate whether the FileStore was completed created. But that means moving the doc creation into filestore (although keeping it unaware of the database and other schema details). So I'm proposing the new FileStore constructor be:
FileStore.
The above will never implicitly create a FileStore that doesn't already exist. And the new `expected_id` kwarg is for subprocesses that create FileStore instances... this is to make sure the doc['_id'] of the FileStore they load matches what the parent process provided them.
And there will also be a new FileStore.create() classmethod:
FileStore.
It will fail if a FileStore already exists in *parentdir*, and will otherwise return a FileStore instance.
Related branches
- James Raymond: Approve
-
Diff: 3188 lines (+1996/-623)9 files modifiedbenchmark-protocol.py (+23/-42)
debian/control (+2/-2)
filestore/__init__.py (+230/-174)
filestore/migration.py (+281/-0)
filestore/misc.py (+16/-8)
filestore/tests/__init__.py (+816/-388)
filestore/tests/run.py (+5/-1)
filestore/tests/test_migration.py (+548/-0)
filestore/tests/test_misc.py (+75/-8)
Changed in filestore: | |
milestone: | 13.04 → 13.05 |
Changed in filestore: | |
status: | In Progress → Fix Committed |
Changed in filestore: | |
status: | Fix Committed → Fix Released |
Note that as it was much easier to first do the V0 => V1 switch over, and then make the FileStore creation always be explicit, that's what I'm doing.
Current work is now happening in lp:~jderose/filestore/explicit-create
lp:~jderose/filestore/migration is being left for reference, but was a dead-end road.