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