Merge branch '2.1.x' into devel

This commit is contained in:
denise 2012-07-04 09:46:30 -04:00
commit bc93119adc
12 changed files with 67 additions and 37 deletions

View file

@ -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))

View file

@ -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 cpoying..." % (src, dst))
media_item['already_exist'] = True
self.logger.debug("file %s already exists in local cache as %s, skipping copying..." % (src, dst))
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

View file

@ -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'])