Demote hard name checks to IOExceptions
because it turns out SAF naming things 'null' is a thing
This commit is contained in:
parent
2aa3a1b4be
commit
f356f56746
1 changed files with 6 additions and 2 deletions
|
@ -178,7 +178,9 @@ internal suspend fun DocumentFile.createOrGetFile(
|
||||||
mimeType: String = MIME_TYPE
|
mimeType: String = MIME_TYPE
|
||||||
): DocumentFile {
|
): DocumentFile {
|
||||||
return findFileBlocking(context, name) ?: createFile(mimeType, name)?.apply {
|
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()
|
} ?: throw IOException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +190,9 @@ internal suspend fun DocumentFile.createOrGetFile(
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
suspend fun DocumentFile.createOrGetDirectory(context: Context, name: String): DocumentFile {
|
suspend fun DocumentFile.createOrGetDirectory(context: Context, name: String): DocumentFile {
|
||||||
return findFileBlocking(context, name) ?: createDirectory(name)?.apply {
|
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()
|
} ?: throw IOException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue