Skip to content

Commit

Permalink
Add more logs to figure out why it sometimes crashes when trying to c…
Browse files Browse the repository at this point in the history
…reate a file with root being FileRoot
  • Loading branch information
K1rakishou committed Mar 1, 2020
1 parent 4fbdcf1 commit ce35572
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ package com.github.k1rakishou.fsaf.file
abstract class Segment(
val name: String,
val isFileName: Boolean = false
)
) {
override fun toString(): String {
return "Segment(name='$name', isFileName=$isFileName)"
}
}

class DirectorySegment(name: String) : Segment(name, false)
class FileSegment(name: String) : Segment(name, true)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ open class ExternalFileManager(
override fun create(baseDir: AbstractFile, segments: List<Segment>): ExternalFile? {
val root = baseDir.getFileRoot<CachingDocumentFile>()
check(root !is Root.FileRoot) {
"create() root is already FileRoot, cannot append anything anymore, root = ${root.holder.uri()}"
"create() root is already FileRoot, cannot append anything anymore, " +
"root = ${root.holder.uri()}, " +
"baseDir segments = ${baseDir.getFileSegments().joinToString()}, " +
"segments = ${segments.joinToString()}"
}

if (segments.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class RawFileManager(
override fun create(baseDir: AbstractFile, segments: List<Segment>): RawFile? {
val root = baseDir.getFileRoot<File>()
check(root !is Root.FileRoot) {
"create() root is already FileRoot, cannot append anything anymore, root = ${root.holder.absolutePath}"
"create() root is already FileRoot, cannot append anything anymore, " +
"root = ${root.holder.absolutePath}, " +
"baseDir segments = ${baseDir.getFileSegments().joinToString()}, " +
"segments = ${segments.joinToString()}"
}

if (segments.isEmpty()) {
Expand Down

0 comments on commit ce35572

Please sign in to comment.