move method

Future<void> move(
  1. VEntity entity,
  2. VFolder into, {
  3. bool $recursing = false,
})

Implementation

Future<void> move(VEntity entity, VFolder into,
    {bool $recursing = false}) async {
  if (entity is VFolder) {
    VFolder newFolder = await mkdir(into.childPath(entity.name));
    List<Future> work = [];

    for (VEntity child in await getChildren(entity).toList()) {
      work.add(move(child, newFolder, $recursing: true));
    }

    await Future.wait(work);
    if (!$recursing) {
      invalidate();
      await delete(entity);
    }
  } else if (entity is VFile) {
    await onMoveFile(entity, into.childPath(entity.name));
    warn("MOVE FILE ${entity.path} -> ${into.childPath(entity.name)}");
  }
}