swift/swift/obj
Peter Portante 7d70e05aeb Refactor DiskFile to hide temp file names and exts
This set of changes reworks the DiskFile class to remove the "extension"
parameter from the put() method, offering the new put_metadata() method with
an optional tombstone keyword boolean, and changes the mkstemp method to only
return the file descriptor.

Reviewing the code it was found that the temporary file name created as a
result of calling DiskFile.mkstemp() was never used by the caller, but the
caller was responsible for passing it back to the DiskFile.put() method. That
seems like too much information is exposed to the caller, when all the caller
requires is the file descriptor to write data into it.

Upon further review, the mkstemp() method was used in three places: PUT, POST
and DELETE method handling. Of those three cases, only PUT requires the file
descriptor, since it is responsible for writing the object contents. For POST
and DELETE, DiskFile only needs to associate metadata with the correct file
name. We abstract the pattern that those two use (once we also refactor the
code to move the fetch of the delete-at metadata, and subsequent
delete-at-update initiation, from under the mkstemp context) by adding the new
put_metadata() method.

As a result, the DiskFile class is then free to do whatever file system
operations it must to meet the API, without the caller having to know more
than just how to write data to a file descriptor. Note that DiskFile itself
key'd off of the '.ts' and '.meta' extensions for its operations, and for that
to work properly, the caller had to know to use those correctly. With this
change, the caller has no knowledge of how the file system is being used to
accomplish data and metadata storage.

See also Question 213796 at:
    https://answers.launchpad.net/swift/+question/213796

Change-Id: I267f68e64391ba627b2a13682393bec62600159d
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2012-11-15 08:58:26 -05:00
..
__init__.py Initial commit of Swift code 2010-07-12 17:03:45 -05:00
auditor.py changed TRUE_VALUES references to utils.config_true_value() call 2012-10-29 13:59:01 -07:00
expirer.py Fixed bugs with internal client and object expirer 2012-11-08 00:05:35 +00:00
replicator.py changed TRUE_VALUES references to utils.config_true_value() call 2012-10-29 13:59:01 -07:00
server.py Refactor DiskFile to hide temp file names and exts 2012-11-15 08:58:26 -05:00
updater.py changed TRUE_VALUES references to utils.config_true_value() call 2012-10-29 13:59:01 -07:00