()
| 408 | sanity_file = cache.get_path('sanity.txt') |
| 409 | |
| 410 | def sanity_is_correct(): |
| 411 | sanity_data = None |
| 412 | # We can't simply check for the existence of sanity_file and then read from |
| 413 | # it here because we don't hold the cache lock yet and some other process |
| 414 | # could clear the cache between checking for, and reading from, the file. |
| 415 | with contextlib.suppress(Exception): |
| 416 | sanity_data = utils.read_file(sanity_file) |
| 417 | if sanity_data == expected: |
| 418 | logger.debug(f'sanity file up-to-date: {sanity_file}') |
| 419 | # Even if the sanity file is up-to-date we still run the checks |
| 420 | # when force is set. |
| 421 | if force: |
| 422 | perform_sanity_checks(quiet) |
| 423 | return True # all is well |
| 424 | return False |
| 425 | |
| 426 | if sanity_is_correct(): |
| 427 | # Early return without taking the cache lock |
no test coverage detected