unmount method

Future<void> unmount(
  1. String mountId, {
  2. bool syncFirst = false,
  3. bool keepRemote = true,
})

Unmounts mountId. With syncFirst, runs a final sync; with keepRemote false, deletes the mount's files on the node (dir mounts only).

Implementation

Future<void> unmount(
  String mountId, {
  bool syncFirst = false,
  bool keepRemote = true,
}) async {
  final record = require(mountId);
  if (syncFirst) {
    try {
      await sync(mountId);
    } on Object {
      // A failed final sync should not block teardown.
    }
  }
  if (!keepRemote && !record.isGit) {
    await _withSession(record, (rpc) async {
      final manifest = await ChannelContentSource(rpc).manifest();
      for (final path in manifest.sortedPaths) {
        await rpc.delete(path);
      }
      return record;
    });
  }
  store.mounts.remove(mountId);
  await store.save();
}