diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/saf/DocumentsStorage.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/saf/DocumentsStorage.kt index 9ad6b2f0..309cc3c9 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/saf/DocumentsStorage.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/saf/DocumentsStorage.kt @@ -178,7 +178,9 @@ internal suspend fun DocumentFile.createOrGetFile( mimeType: String = MIME_TYPE ): DocumentFile { return findFileBlocking(context, name) ?: createFile(mimeType, name)?.apply { - check(this.name == name) { "File named ${this.name}, but should be $name" } + if (this.name != name) { + throw IOException("File named ${this.name}, but should be $name") + } } ?: throw IOException() } @@ -188,7 +190,9 @@ internal suspend fun DocumentFile.createOrGetFile( @Throws(IOException::class) suspend fun DocumentFile.createOrGetDirectory(context: Context, name: String): DocumentFile { return findFileBlocking(context, name) ?: createDirectory(name)?.apply { - check(this.name == name) { "Directory named ${this.name}, but should be $name" } + if (this.name != name) { + throw IOException("Directory named ${this.name}, but should be $name") + } } ?: throw IOException() }