deleteCollection method
Delete a collection from your store
Implementation
Future<bool> deleteCollection({
required String path,
PeerId? toServer,
}) async {
final serverId = toServer ?? await _serverSelector.selectServer(config.preferredServers);
if (serverId == null) {
_logger.warning('No S&F server available for collection deletion');
return false;
}
try {
final context = Context();
final stream = await host.newStream(
serverId,
[CollectionHandler.protocolId],
context,
).timeout(config.connectionTimeout);
final response = await CollectionHandler.deleteCollection(
stream,
ownerPeerId: host.id,
path: path,
).timeout(config.messageTimeout);
await stream.close();
return response.isSuccess;
} on TimeoutException {
_logger.warning('DELETE collection timed out');
return false;
} catch (e) {
_logger.warning('Failed to DELETE collection: $e');
return false;
}
}