OSTree.MutableTree

g GObject.Object GObject.Object OSTree.MutableTree OSTree.MutableTree GObject.Object->OSTree.MutableTree

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_from_checksum (repo, contents_checksum, metadata_checksum)

class

new_from_commit (repo, rev)

check_error ()

ensure_dir (name)

ensure_parent_dirs (split_path, metadata_checksum)

fill_empty_from_dirtree (repo, contents_checksum, metadata_checksum)

get_contents_checksum ()

get_files ()

get_metadata_checksum ()

get_subdirs ()

lookup (name)

remove (name, allow_noent)

replace_file (name, checksum)

set_contents_checksum (checksum)

set_metadata_checksum (checksum)

walk (split_path, start)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class OSTree.MutableTree(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

OSTree.MutableTreeClass

Private instance structure.

classmethod new()
Returns:

A new tree

Return type:

OSTree.MutableTree

classmethod new_from_checksum(repo, contents_checksum, metadata_checksum)
Parameters:
  • repo (OSTree.Repo) – The repo which contains the objects refered by the checksums.

  • contents_checksum (str) – dirtree checksum

  • metadata_checksum (str) – dirmeta checksum

Returns:

A new tree

Return type:

OSTree.MutableTree

Creates a new OSTree.MutableTree with the contents taken from the given repo and checksums. The data will be loaded from the repo lazily as needed.

New in version 2018.7.

classmethod new_from_commit(repo, rev)
Parameters:
  • repo (OSTree.Repo) – The repo which contains the objects refered by the checksums.

  • rev (str) – ref or SHA-256 checksum

Raises:

GLib.Error

Returns:

A new tree

Return type:

OSTree.MutableTree

Creates a new OSTree.MutableTree with the contents taken from the given commit. The data will be loaded from the repo lazily as needed.

New in version 2021.5.

check_error()
Raises:

GLib.Error

Returns:

TRUE on success

Return type:

bool

In some cases, a tree may be in a “lazy” state that loads data in the background; if an error occurred during a non-throwing API call, it will have been cached. This function checks for a cached error. The tree remains in error state.

New in version 2018.7.

ensure_dir(name)
Parameters:

name (str) – Name of subdirectory of self to retrieve/creates

Raises:

GLib.Error

Returns:

out_subdir:

the subdirectory

Return type:

(bool, out_subdir: OSTree.MutableTree)

Returns the subdirectory of self with filename name, creating an empty one it if it doesn’t exist.

ensure_parent_dirs(split_path, metadata_checksum)
Parameters:
  • split_path ([str]) – File path components

  • metadata_checksum (str) – SHA256 checksum for metadata

Raises:

GLib.Error

Returns:

out_parent:

The parent tree

Return type:

(bool, out_parent: OSTree.MutableTree)

Create all parent trees necessary for the given split_path to exist.

fill_empty_from_dirtree(repo, contents_checksum, metadata_checksum)
Parameters:
Returns:

True if merge was successful, False if it was not possible.

This function enables optimisations when composing trees. The provided checksums are not loaded or checked when this function is called. Instead the contents will be loaded only when needed.

Return type:

bool

Merges self with the tree given by contents_checksum and metadata_checksum, but only if it’s possible without writing new objects to the repo. We can do this if either self is empty, the tree given by contents_checksum is empty or if both trees already have the same contents_checksum.

New in version 2018.7.

get_contents_checksum()
Return type:

str

get_files()
Returns:

All children files (the value is a checksum)

Return type:

{str: str}

get_metadata_checksum()
Return type:

str

get_subdirs()
Returns:

All children directories

Return type:

{str: OSTree.MutableTree}

lookup(name)
Parameters:

name (str) – name

Raises:

GLib.Error

Returns:

True on success and either out_file_checksum or out_subdir are filled, False otherwise.

out_file_checksum:

checksum

out_subdir:

subdirectory

Return type:

(bool, out_file_checksum: str or None, out_subdir: OSTree.MutableTree or None)

Lookup name and returns out_file_checksum or out_subdir depending on its file type.

remove(name, allow_noent)
Parameters:
  • name (str) – Name of file or subdirectory to remove

  • allow_noent (bool) – If False, an error will be thrown if name does not exist in the tree

Raises:

GLib.Error

Return type:

bool

Remove the file or subdirectory named name from the mutable tree self.

New in version 2018.9.

replace_file(name, checksum)
Parameters:
  • name (str) –

  • checksum (str) –

Raises:

GLib.Error

Return type:

bool

set_contents_checksum(checksum)
Parameters:

checksum (str) –

set_metadata_checksum(checksum)
Parameters:

checksum (str) –

walk(split_path, start)
Parameters:
  • split_path ([str]) – Split pathname

  • start (int) – Descend from this number of elements in split_path

Raises:

GLib.Error

Returns:

out_subdir:

Target parent

Return type:

(bool, out_subdir: OSTree.MutableTree)

Traverse start number of elements starting from split_path; the child will be returned in out_subdir.