mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
Scope check_file()
search space (#4933)
`check_file()` is now limited to searching opt-in directories: /data, /models, /utils. This prevents large non-project directories like /.git and /venv from being searched, which may cause `check_file()` to slow significantly.
This commit is contained in:
parent
793383232f
commit
5a8e4343d8
@ -315,7 +315,9 @@ def check_file(file, suffix=''):
|
||||
assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check
|
||||
return file
|
||||
else: # search
|
||||
files = glob.glob('./**/' + file, recursive=True) # find file
|
||||
files = []
|
||||
for d in 'data', 'models', 'utils': # search directories
|
||||
files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file
|
||||
assert len(files), f'File not found: {file}' # assert file was found
|
||||
assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assert unique
|
||||
return files[0] # return file
|
||||
|
Loading…
x
Reference in New Issue
Block a user