CC-4058: Timeline -> Cannot add song twice if last cursor is selected

-fixed
This commit is contained in:
Martin Konecny 2012-07-03 17:06:35 -04:00
parent 42f4757288
commit 00745d372d
3 changed files with 12 additions and 6 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 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

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