Skip to content

Commit

Permalink
FsCrawler - cache currentThread
Browse files Browse the repository at this point in the history
  • Loading branch information
d-kozak committed Jan 14, 2020
1 parent 5d4376e commit 78124ef
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ internal class FsCrawler(
*/
var directoryCount = 0

/**
* current thread reference, it is expensive to ask about it every time
*/
private val currentThread: Thread = Thread.currentThread()

/**
* Crawl the fs tree starting from the diskRoot
* @return fs tree
Expand All @@ -47,14 +52,15 @@ internal class FsCrawler(
}
}


/**
* Crawl the fs tree starting from given file
* @param file to be crawled
* @param currentDepth depth of depth-first search
*/
@Precondition("currentFile.exists")
fun recursiveScan(currentFile: File, currentDepth: Int = 0): TreeItem<FsNode> {
if (Thread.currentThread().isInterrupted) {
if (currentThread.isInterrupted) {
logger.info { "Cancelation detected" }
throw InterruptedException()
}
Expand Down

0 comments on commit 78124ef

Please sign in to comment.