diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 4e2cfaf29..4e350d59c 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -429,7 +429,7 @@ class PypoFetch(Thread): fileExt = os.path.splitext(media_item['uri'])[1] dst = os.path.join(download_dir, media_item['id'] + fileExt) media_item['dst'] = dst - media_item['started_copying'] = False + media_item['file_ready'] = False media_filtered[key] = media_item self.media_prepare_queue.put(copy.copy(media_filtered)) diff --git a/python_apps/pypo/pypofile.py b/python_apps/pypo/pypofile.py index a3d21af6a..67e829464 100644 --- a/python_apps/pypo/pypofile.py +++ b/python_apps/pypo/pypofile.py @@ -60,22 +60,28 @@ class PypoFile(Thread): except Exception, e: dst_exists = False - media_item['already_exist'] = False do_copy = False if dst_exists: if src_size != dst_size: do_copy = True else: self.logger.debug("file %s already exists in local cache as %s, skipping copying..." % (src, dst)) - media_item['already_exist'] = True else: do_copy = True + media_item['file_ready'] = not do_copy + if do_copy: self.logger.debug("copying from %s to local cache %s" % (src, dst)) try: - media_item['started_copying'] = True + """ + List file as "ready" before it starts copying because by the time + Liquidsoap is ready to play this file, it should have at least started + copying (and can continue copying while Liquidsoap reads from the beginning + of the file) + """ + media_item['file_ready'] = True """ copy will overwrite dst if it already exists diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index cb71937a3..67191f81f 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -340,11 +340,11 @@ class PypoPush(Thread): give up on it. """ iter_num = 0 - while not media_item['started_copying'] and iter_num < 50: + while not media_item['file_ready'] and iter_num < 50: time.sleep(0.1) iter_num += 1 - if media_item['started_copying'] or media_item['already_exist']: + if media_item['file_ready']: self.telnet_to_liquidsoap(media_item) else: self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst'])