begin static method

ProjectTransaction begin(
  1. JustProject project, {
  2. DateTime? now,
  3. required String trash,
  4. String trashRoot = defaultTrashRoot,
})

Starts a change to project, stamped now, whose replaced folders go to <trashRoot>/<trash>/<stamp>/ when it commits. Both are kept in the journal, so recover finishes a change the same way.

Implementation

static ProjectTransaction begin(
  JustProject project, {
  DateTime? now,
  required String trash,
  String trashRoot = defaultTrashRoot,
}) {
  final stamp = timeStamp((now ?? DateTime.now()).toUtc());
  var dir = project.dir('$journals/$stamp');
  for (var n = 1; dir.existsSync(); n++) {
    dir = project.dir('$journals/$stamp-$n');
  }
  dir.createSync(recursive: true);
  return ProjectTransaction._(project, dir, trash, trashRoot).._save();
}