@@ -105,9 +105,13 @@ class CryptoContainer
105105 recipients.addAll(recipientsToAdd)
106106 }
107107
108- fun getDataFiles (): List <File > = dataFiles
108+ fun getDataFiles (): List <File > =
109+ dataFiles
110+ .toList()
109111
110- fun getRecipients (): List <Addressee > = recipients
112+ fun getRecipients (): List <Addressee > =
113+ recipients
114+ .toList()
111115
112116 fun hasRecipients (): Boolean = recipients.isNotEmpty()
113117
@@ -136,25 +140,21 @@ class CryptoContainer
136140 throw ContainerDataFilesEmptyException ()
137141 }
138142
139- val files = getDataFiles()
140143 withContext(IO ) {
141- for (i in files.indices) {
142- if (dataFile.name == files[i].name) {
143- dataFiles.removeAt(i)
144- break
145- }
144+ val index = dataFiles.indexOfFirst { it.name == dataFile.name }
145+ if (index != - 1 ) {
146+ dataFiles.removeAt(index)
146147 }
147148 }
148149 }
149150
150151 @Throws(Exception ::class )
151- fun removeRecipient (recipient : Addressee ) {
152- val signatures = getRecipients()
153- if (signatures.isNotEmpty()) {
154- for (i in signatures.indices) {
155- if (recipient.identifier == signatures[i].identifier) {
156- recipients.removeAt(i)
157- break
152+ suspend fun removeRecipient (recipient : Addressee ) {
153+ if (recipients.isNotEmpty()) {
154+ withContext(IO ) {
155+ val index = recipients.indexOfFirst { it.identifier == recipient.identifier }
156+ if (index != - 1 ) {
157+ recipients.removeAt(index)
158158 }
159159 }
160160 }
0 commit comments