createRepository method
- required String path,
- SetLocalSecret? readSecret,
- SetLocalSecret? writeSecret,
- ShareToken? token,
- bool syncEnabled = false,
- bool dhtEnabled = false,
- 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 asread_secret
if one wants to use only one secret for both reading and writing. Separate secrets are useful for plausible deniability. If bothread_secret
andwrite_secret
areNone
, the repo won't be protected and anyone with physical access to the device will be able to read and write to it. Ifread_secret
is notNone
butwrite_secret
isNone
, the repo won't be writable from this device.token
: used to share repositories between devices. If notNone
, this repo will be linked with the repos with the same token on other devices. See alsoSelf::repository_share
. This also determines the maximal access mode the repo can be opened in. IfNone
, 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();
}
}