createRepository method

Future<Repository> createRepository({
  1. required String path,
  2. SetLocalSecret? readSecret,
  3. SetLocalSecret? writeSecret,
  4. ShareToken? token,
  5. bool syncEnabled = false,
  6. bool dhtEnabled = false,
  7. bool pexEnabled = false,
})
inherited

Creates a new repository.

  • path: path to the repository file or name of the repository.
  • read_secret: local secret for reading the repository on this device only. Do not share with peers!. If null, the repo won't be protected and anyone with physical access to the device will be able to read it.
  • write_secret: local secret for writing to the repository on this device only. Do not share with peers! Can be the same as read_secret if one wants to use only one secret for both reading and writing. Separate secrets are useful for plausible deniability. If both read_secret and write_secret are None, the repo won't be protected and anyone with physical access to the device will be able to read and write to it. If read_secret is not None but write_secret is None, the repo won't be writable from this device.
  • token: used to share repositories between devices. If not None, this repo will be linked with the repos with the same token on other devices. See also Self::repository_share. This also determines the maximal access mode the repo can be opened in. If None, it's write mode.

Implementation

Future<Repository> createRepository({
  required String path,
  SetLocalSecret? readSecret,
  SetLocalSecret? writeSecret,
  ShareToken? token,
  bool syncEnabled = false,
  bool dhtEnabled = false,
  bool pexEnabled = false,
}) async {
  final request = RequestSessionCreateRepository(
    path: path,
    readSecret: readSecret,
    writeSecret: writeSecret,
    token: token,
    syncEnabled: syncEnabled,
    dhtEnabled: dhtEnabled,
    pexEnabled: pexEnabled,
  );
  final response = await client.invoke(request);
  switch (response) {
    case ResponseRepository(value: final value): return Repository(client, value);
    default: throw UnexpectedResponse();
  }
}