resolveOrCreateFolder method

Future<Map<String, dynamic>> resolveOrCreateFolder(
  1. String path
)

Implementation

Future<Map<String, dynamic>> resolveOrCreateFolder(String path) async {
  try {
    final info = await resolvePath(path);
    if (info['type'] != 'folder') {
      throw Exception("Path exists but is not a folder");
    }
    return info;
  } on Exception catch (e) {
    if (e.toString().contains("Path not found")) {
      api.log("Creating target folder: $path");
      return await createFolderRecursive(path);
    }
    rethrow;
  }
}