Whole file
jupyter/jupyter-packaging
The author described this change as “Fix is_stale for file paths”. It counts as a record because the check below fails on the code as it stood at ffea6a0db and passes on 4ccb7b7ac, with nothing else changed between the two runs.
Projectjupyter/jupyter-packaging
Fix saved2017-04-20
Sharing licenceBSD-3-Clause · LICENSE
Change size+10 −1
What the code was meant to do, written into the code itself as a save note
Fix is_stale for file paths
The change
| 128 | 128 | """ | |
| 129 | 129 | if not os.path.exists(target): | |
| 130 | 130 | return True | |
| 131 | - | target_mtime = recursive_mtime(target) | |
| 131 | + | target_mtime = recursive_mtime(target) or 0 | |
| 132 | 132 | return compare_recursive_mtime(source, cutoff=target_mtime) | |
| 133 | 133 | ||
| 134 | 134 | ||
| ⋯ | |||
| 179 | 179 | E.g. if newest=True, and a file in path is newer than the cutoff, it will | |
| 180 | 180 | return True. | |
| 181 | 181 | """ | |
| 182 | + | if os.path.isfile(path): | |
| 183 | + | mt = mtime(path) | |
| 184 | + | if newest: | |
| 185 | + | if mt > cutoff: | |
| 186 | + | return True | |
| 187 | + | elif mt < cutoff: | |
| 188 | + | return True | |
| 182 | 189 | for dirname, _, filenames in os.walk(path, topdown=False): | |
| 183 | 190 | for filename in filenames: | |
| 184 | 191 | mt = mtime(pjoin(dirname, filename)) | |
| ⋯ | |||
| 192 | 199 | ||
| 193 | 200 | def recursive_mtime(path, newest=True): | |
| 194 | 201 | """Gets the newest/oldest mtime for all files in a directory.""" | |
| 202 | + | if os.path.isfile(path): | |
| 203 | + | return mtime(path) | |
| 195 | 204 | current_extreme = None | |
| 196 | 205 | for dirname, _, filenames in os.walk(path, topdown=False): | |
| 197 | 206 | for filename in filenames: | |
The check that tells the two apart
fail→pass·tests/test_is_stale.py::test_file_vs_dir
Check file tests/test_is_stale.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itffea6a0dbfd6d8e77fbcb5c436a0323d92d0e8ed
Broken version dated2017-04-19
Modulejupyter_packaging.setupbase
Units changedcompare_recursive_mtime, is_stale, recursive_mtime
Fingerprint22381053e0fae523
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.