Description
def getPathSize(fs: FileSystem, path: Path): Long = { val fileStatus = fs.getFileStatus(path) val size = if (fileStatus.isDirectory) { fs.listStatus(path) .map { status => if (isDataPath(status.getPath, stagingDir)) { getPathSize(fs, status.getPath) } else { 0L } }.sum } else { fileStatus.getLen } size }
Change input parameter from `Path` to `FileStatus`, there is no need to do `fs.getFileStatus(path)` after each recursive call.