(FilesFacade ff, Path path, boolean topLevel, StringSink sink)
| 332 | } |
| 333 | |
| 334 | private long getDirSize(FilesFacade ff, Path path, boolean topLevel, StringSink sink) { |
| 335 | long totalSize = 0L; |
| 336 | |
| 337 | final long pFind = ff.findFirst(path.$()); |
| 338 | if (pFind > 0L) { |
| 339 | final int len = path.size(); |
| 340 | try { |
| 341 | do { |
| 342 | if (hasTimedOut()) { |
| 343 | return 0L; |
| 344 | } |
| 345 | |
| 346 | final long nameUtf8Ptr = ff.findName(pFind); |
| 347 | path.trimTo(len).concat(nameUtf8Ptr).$(); |
| 348 | if (ff.findType(pFind) == DT_FILE) { |
| 349 | totalSize += ff.length(path.$()); |
| 350 | } else if (notDots(nameUtf8Ptr)) { |
| 351 | if (topLevel) { |
| 352 | sink.clear(); |
| 353 | Utf8s.utf8ToUtf16(path, len + 1, path.size(), sink); |
| 354 | final int tableNameLen = Chars.indexOf(sink, SYSTEM_TABLE_NAME_SUFFIX); |
| 355 | if (tableNameLen > -1) { |
| 356 | sink.trimTo(tableNameLen); |
| 357 | } |
| 358 | if (!TableUtils.isValidTableName(sink, maxFileNameLen)) { |
| 359 | // This is not a table, skip |
| 360 | continue; |
| 361 | } |
| 362 | } |
| 363 | totalSize += getDirSize(ff, path, false, sink); |
| 364 | } |
| 365 | } |
| 366 | while (ff.findNext(pFind) > 0); |
| 367 | } finally { |
| 368 | ff.findClose(pFind); |
| 369 | path.trimTo(len); |
| 370 | } |
| 371 | } |
| 372 | return totalSize; |
| 373 | } |
| 374 | |
| 375 | protected boolean hasTimedOut() { |
| 376 | return clock.getTicks() - dbSizeEstimateStartTimestamp > dbSizeEstimateTimeout; |
no test coverage detected