fix download state
This commit is contained in:
parent
7d27c4f3a1
commit
dc7ff544a7
2 changed files with 11 additions and 10 deletions
|
@ -8,6 +8,7 @@ import re
|
|||
import shutil
|
||||
import stat
|
||||
import unicodedata
|
||||
import time
|
||||
|
||||
import ox
|
||||
from sqlalchemy.orm import load_only
|
||||
|
@ -508,13 +509,13 @@ class Item(db.Model):
|
|||
|
||||
def queue_download(self):
|
||||
u = state.user()
|
||||
if not self.id in state.downloads.transfers:
|
||||
state.downloads.transfers[self.id] = {
|
||||
'added': datetime.utcnow(),
|
||||
'progress': 0
|
||||
}
|
||||
logger.debug('queue %s for download', self.id)
|
||||
if not u in self.users:
|
||||
if not self.id in state.downloads.transfers:
|
||||
state.downloads.transfers[self.id] = {
|
||||
'added': datetime.utcnow(),
|
||||
'progress': 0
|
||||
}
|
||||
logger.debug('queue %s for download', self.id)
|
||||
self.add_user(u)
|
||||
|
||||
def save_file(self, content):
|
||||
|
@ -846,7 +847,6 @@ def get_cover(id):
|
|||
|
||||
|
||||
def get_preview(id):
|
||||
delay = 60
|
||||
if state.online:
|
||||
#logger.debug('get_preview(%s)', id)
|
||||
with db.session():
|
||||
|
@ -854,7 +854,8 @@ def get_preview(id):
|
|||
if i:
|
||||
i.get_preview()
|
||||
else:
|
||||
state.main.call_later(delay, lambda: state.tasks.queue('getpreview', id))
|
||||
state.tasks.queue('getpreview', id)
|
||||
time.sleep(0.5)
|
||||
|
||||
def sync_metadata(ids=None):
|
||||
#logger.debug('sync_metadata(%s)', len(ids) if len(ids) > 10 else ids)
|
||||
|
|
|
@ -318,10 +318,10 @@ class List(db.Model):
|
|||
for item_id in items:
|
||||
i = Item.get(item_id)
|
||||
if i:
|
||||
if i.info['mediastate'] != 'available' and self.user_id == settings.USER_ID:
|
||||
i.queue_download()
|
||||
if i not in self.items:
|
||||
self.items.append(i)
|
||||
if self.user_id == settings.USER_ID:
|
||||
i.queue_download()
|
||||
i.update(commit=False)
|
||||
if i.info['mediastate'] == 'available':
|
||||
available_items.append(item_id)
|
||||
|
|
Loading…
Reference in a new issue