Skip to content

Commit d582ffa

Browse files
committed
Start fixing #5
1 parent 19dd25d commit d582ffa

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

app.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
app.config["api_route"] = "/api/v1"
2929

3030
def 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("/")
4043
def index():

tasks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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]

0 commit comments

Comments
 (0)