Fix bug where files downloaded directly do not exist when the watchdog event fires
This commit is contained in:
parent
23f68f19e8
commit
7b1e03bf8e
1 changed files with 11 additions and 0 deletions
11
converter.py
11
converter.py
|
|
@ -71,6 +71,17 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
|
||||||
def on_created(self, event):
|
def on_created(self, event):
|
||||||
print('File found: {}'.format(event.src_path))
|
print('File found: {}'.format(event.src_path))
|
||||||
|
|
||||||
|
fileExists = False
|
||||||
|
timeout = 0
|
||||||
|
while not fileExists:
|
||||||
|
fileExists = os.path.isfile(event.src_path)
|
||||||
|
time.sleep(1)
|
||||||
|
timeout += 1
|
||||||
|
|
||||||
|
if timeout > 10:
|
||||||
|
print('Timeout waiting for file {} to exist. Aborting processing.'.format(event.src_path))
|
||||||
|
return
|
||||||
|
|
||||||
historicalSize = -1
|
historicalSize = -1
|
||||||
while (historicalSize != os.path.getsize(event.src_path)):
|
while (historicalSize != os.path.getsize(event.src_path)):
|
||||||
historicalSize = os.path.getsize(event.src_path)
|
historicalSize = os.path.getsize(event.src_path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue