File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828app .config ["api_route" ] = "/api/v1"
2929
3030def get_files (target , ext_filter = []):
31- for file in sorted (os .listdir (target )):
32- path = os .path .join (target , file )
33- if os .path .isfile (path ):
34- if os .path .splitext (file )[1 ] in ext_filter or ext_filter == []:
35- yield (
36- os .path .splitext (file )[0 ]
37- )
31+ try :
32+ for file in sorted (os .listdir (target )):
33+ path = os .path .join (target , file )
34+ if os .path .isfile (path ):
35+ if os .path .splitext (file )[1 ] in ext_filter or ext_filter == []:
36+ yield (
37+ os .path .splitext (file )[0 ]
38+ )
39+ except FileNotFoundError :
40+ return None
3841
3942@app .route ("/" )
4043def index ():
Original file line number Diff line number Diff line change @@ -49,7 +49,11 @@ def stop_running(signum, frame):
4949 logger .debug ("Scanning '%s' for new files" , watch )
5050 old_files = files
5151 files = {}
52- file_list = [f for f in os .listdir (watch ) if os .path .isfile (pathlib .Path .joinpath (watch , f ))]
52+ try :
53+ file_list = [f for f in os .listdir (watch ) if os .path .isfile (pathlib .Path .joinpath (watch , f ))]
54+ except FileNotFoundError :
55+ logger .error ("Folder on disk doesn't exist or is inaccessible: %s" , watch )
56+ break
5357 for video in file_list :
5458 files [video ] = {}
5559 new_file = files [video ]
You can’t perform that action at this time.
0 commit comments