TomGitStorage class

Documents in git repositories: on a server reached over smart HTTP(S), or in a folder on this device.

  • The medium is a local clone — openClone supplies it, a directory (package:tom_core_storage/io.dart) or memory. Only the branch a document is on is fetched, and only when its tip is not already here.
  • A head is the document's object id in the branch tip: the blob of a single-file container, the tree of a folder. Another document changing on the same branch does not move it.
  • A commit is a compare-and-swap on that head, then a push. When the push is refused because somebody else moved the branch, the branch is fetched again; if this document is still where the caller expected, the commit is rebuilt on the new tip and pushed again, and if it is not, the caller gets a TomCasConflictException and merges, as with every other backend.
  • Credentials come from tokens by the repository's host: the token is the HTTP password, under the token's account name or x-access-token.
  • A folder on this device (git:file:///…) is read and written in place when openLocal is given: there is nothing to fetch, and a commit moves the branch under git's ref lock, compare-and-swap on its old tip, so git and this backend can write the same repository. A branch some working tree has checked out is read but never written — the tree and its index would be left describing the commit before, which is why git itself refuses a push to such a branch. Without openLocal (a build with no file system) file: locators are not this backend's.
Inheritance

Constructors

TomGitStorage({required TomGitCloneOpener openClone, TomGitLocalOpener? openLocal, TomTokenSource? tokens, Client? client, ({String email, String name}) committer()?, String commitMessagePrefix = '', int maxPushAttempts = 5, int? maxObjectBytes})

Properties

commitMessagePrefix → String
final
hashCode → int
The hash code for this object.
no setterinherited
maxObjectBytes → int?
The largest a single path in a TomChangeset may be, or null when the backend imposes no limit of its own.
no setteroverride
maxPushAttempts → int
How often a commit is rebuilt and pushed again after losing a race to a change elsewhere on the branch.
final
openClone → TomGitCloneOpener
final
openLocal → TomGitLocalOpener?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tokens → TomTokenSource?
final

Methods

adoptBackoff(TomBackoffPolicy policy) → void
Adopts how long to hold off after a rate limit that stated no instant.
inherited
cacheMetaScope(String location) → List<String>?
The meta/ key prefix this backend keeps the records for the storage location location under, or null when it keeps none.
inherited
close() → void
override
commit(String locator, TomChangeset changeset, {String? expectedHead, String? message, TomCommitProgressSink? onProgress}) → Future<String>
Applies changeset atomically, refusing the write if the container has moved away from expectedHead.
override
delete(String locator) → Future<void>
Removes the whole container.
override
handles(String locator) → bool
Whether this backend owns locator's scheme.
override
headOf(String locator) → Future<String?>
The current revision of the container, or null when it does not exist.
override
headsOf(Iterable<String> locators) → Future<Map<String, String?>>
One listing per repository, however many documents it holds.
override
list(String locator) → Future<List<TomStorageEntry>>
Entries directly inside the container at locator.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readBundle(String locator) → Future<TomBundleMedium>
The directory-shaped bundle at locator, as a detached medium.
override
readBytes(String locator) → Future<Uint8List>
The bytes of the single-file artifact at locator.
override
toString() → String
A string representation of this object.
inherited
withinPass<T>(Future<T> body()) → Future<T>
Runs body as one pass: a stretch of work whose reads may share what the pass has already established about the remote.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

lfsRemedy → const String