revert a part of getFileDocument, add another check

This commit is contained in:
tibbi 2017-08-03 18:22:04 +02:00
parent 8b60ef6e75
commit e1215e7b0e
2 changed files with 9 additions and 20 deletions

View file

@ -29,7 +29,7 @@ ext {
propMinSdkVersion = 16
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '2.23.4'
propVersionName = '2.23.6'
kotlin_version = '1.1.3-2'
support_libs = '25.3.1'
}

View file

@ -351,25 +351,14 @@ fun BaseSimpleActivity.getFileDocument(path: String): DocumentFile? {
var document = DocumentFile.fromTreeUri(this, Uri.parse(baseConfig.treeUri))
val parts = relativePath.split("/")
for (i in 0..parts.size - 1) {
var currDocument = document.findFile(parts[i])
if (currDocument != null) {
for (part in parts) {
val currDocument = document.findFile(part)
if (currDocument != null)
document = currDocument
} else {
// We need to assure that we transverse to the right directory!
if (i == parts.size - 1) {
// The last document should be the file we're looking for, not a directory
currDocument = document.createFile("", parts[i])
} else {
currDocument = document.createDirectory(parts[i])
}
if (currDocument == null) {
toast(R.string.unknown_error_occurred)
return null
}
document = currDocument
}
}
return document
return if (document.name == path.getFilenameFromPath())
document
else
null
}