Commit graph

64 commits

Author SHA1 Message Date
Christian Kellner
399606528c objectstore: helper to create temp dirs inside the store
Create a small helper method that creates a new temporary directory
of type tempfile.TemporaryDirectory within the store and returns it.
2020-02-28 16:11:49 +01:00
Christian Kellner
d10537da42 objectstore: yield Object not path from .new()
Instead of just returning the path of the temporary object that is
created in .new() the actual instance of the new `Object` is being
returned, which can then provide a richer interface for clients
than a plain directory path.
2020-02-28 16:11:49 +01:00
Christian Kellner
52736169f1 objectstore: Object keeps reference to store
Keep are reference to the parent store, which this object is tied
to. It is currently not yet used directly but is a preparation for
a closer Object and ObjectStore integration that will happen in
commits to follow.
2020-02-28 16:11:49 +01:00
Christian Kellner
19f49e5dc3 objectstore: rename TreeObject to Object
As the name implies, the ObjectStore stores objects, which can be
trees but also everything an Assembler can make of the input tree,
like qcow2 images, tarballs and other non tree-like outputs.
Therefore rename the TreeObject to Object to better reflect that it
is representing any object, not only trees, in the store.
2020-02-28 16:11:49 +01:00
Christian Kellner
3b7c87d563 objectstore: helper to resolve references to paths
Introduce a small helper function to resolve object_id references
into their paths inside the object store and use that throughout
the store.
2020-02-28 16:11:49 +01:00
Christian Kellner
5a61d8c869 objectstore: extract method to open a TreeObject
Extract the opening a TreeObject out of the treesum property so
that the latter is easier to read.
2020-02-06 16:10:35 +01:00
Christian Kellner
ce5719a03f objectstore: move tree-moving code into the tree
The code to move the a TreeObject more naturally belongs to the
TreeObject itself and makes the ObjectStore.commit() method even
easier to read.
2020-02-06 16:10:35 +01:00
Christian Kellner
b5b5e7be29 objectstore: also ignore EEXIST when committing
When the tree is committed to the objects directory of the object-
store, it is done via rename(3). The two possible errors that can
be raised in case that a non-empty tree with the same name already
exist is [EEXIST] or [ENOTEMPTY]. The latter was already ignored
but the former was not. At least on btrfs former will be raised

  File "/home/gicmo/Code/src/osbuild/osbuild/objectstore.py",
    os.rename(tree.root, output_tree)
  FileExistsError: [Errno 17] File exists: 'store/tmpyyi3yvie/tree' -> 'store/objects/…'
2020-02-06 16:10:35 +01:00
Christian Kellner
3a40d31bee objectstore: introduce tree snapshot support
Add a new method to the ObjectStore that takes a path to a file
system tree, which is currently being built, and commits it to
the store and references it via a given object_id.
The tree is copied to a temporary location (co-located in the
store to enable fast copying via reflinks) and then atomically
moved into the ObjectStore's objects path via rename(3).
2020-02-06 16:10:35 +01:00
Christian Kellner
db8618f192 objectstore: extract logic to commit a tree
Extract the code from ObjectStore.new that will commit the filled
tree to the store into its own method so it can be used from a
future method to snapshot trees at random points in time.
2020-02-06 16:10:35 +01:00
Christian Kellner
4831927e84 objectstore: introduce TreeObject
Introduce a small `TreeObject` class that is the representation of
a tree during its construction. It supports calculating its treesum
as well initialize the new tree with an existing one.
2020-02-06 16:10:35 +01:00
Lars Karlitski
cb173f7d3c objectstore: refer to objects, not trees
Also simplify method names with redundant words:

  has_tree → contains
  get_tree → get
  new_tree → new
2019-09-25 23:50:50 +02:00
Lars Karlitski
f1151a1719 objectstore: clarify ENOTEMPTY handling 2019-09-25 23:50:50 +02:00
Tom Gundersen
679b79c5e5 osbuild: split package into separate files
Import modules between files using the syntax `from . import foobar`,
renaming what used to be `FooBar` to `foobar.FooBar` when moved to a
separate file.

In __init__.py only import what is meant to be public API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-21 09:56:50 +04:00