mirror of https://github.com/evilhero/mylar
FIX:(#295) IndexError when starting Mylar with an empty DB
This commit is contained in:
parent
ed6f6e93a9
commit
335393a99a
|
@ -381,23 +381,6 @@ def apiremove(apistring, type):
|
|||
|
||||
return apiremoved
|
||||
|
||||
#def ComicSort(imported=None):
|
||||
#from mylar import db, logger
|
||||
#myDB = db.DBConnection()
|
||||
#if imported != None:
|
||||
#if it's an Add Series, set it to the last record for now so it doesn't throw a 500.
|
||||
#cid = {"ComicID": imported}
|
||||
#val = {"SortOrder": 999}
|
||||
# comicorder.append({
|
||||
# 'ComicID': imported,
|
||||
# 'SortOrder': 999
|
||||
# })
|
||||
|
||||
# issue['issuechoice'] = issuechoice
|
||||
|
||||
# myDB.upsert("comics", val, cid)
|
||||
# logger.info("New Series...Set SortOrder to last record to avoid errors for now.")
|
||||
#else:
|
||||
def ComicSort(comicorder=None,sequence=None,imported=None):
|
||||
if sequence:
|
||||
# if it's on startup, load the sql into a tuple for use to avoid record-locking
|
||||
|
@ -409,7 +392,7 @@ def ComicSort(comicorder=None,sequence=None,imported=None):
|
|||
comicorder = {}
|
||||
comicidlist = []
|
||||
if sequence == 'update':
|
||||
mylar.COMICSORT['SortOrder'] == None
|
||||
mylar.COMICSORT['SortOrder'] = None
|
||||
mylar.COMICSORT['LastOrderNo'] = None
|
||||
mylar.COMICSORT['LastOrderID'] = None
|
||||
for csort in comicsort:
|
||||
|
@ -421,7 +404,8 @@ def ComicSort(comicorder=None,sequence=None,imported=None):
|
|||
'ComicOrder': i
|
||||
})
|
||||
elif sequence == 'update':
|
||||
mylar.COMICSORT['SortOrder'].append({
|
||||
comicorderlist.append({
|
||||
# mylar.COMICSORT['SortOrder'].append({
|
||||
'ComicID': csort['ComicID'],
|
||||
'ComicOrder': i
|
||||
})
|
||||
|
@ -429,14 +413,25 @@ def ComicSort(comicorder=None,sequence=None,imported=None):
|
|||
comicidlist.append(csort['ComicID'])
|
||||
i+=1
|
||||
if sequence == 'startup':
|
||||
comicorder['SortOrder'] = comicorderlist
|
||||
comicorder['LastOrderNo'] = i-1
|
||||
comicorder['LastOrderID'] = comicorder['SortOrder'][i-1]['ComicID']
|
||||
if i == 0:
|
||||
comicorder['SortOrder'] = ({'ComicID':'99999','ComicOrder':1})
|
||||
comicorder['LastOrderNo'] = 1
|
||||
comicorder['LastOrderID'] = 99999
|
||||
else:
|
||||
comicorder['SortOrder'] = comicorderlist
|
||||
comicorder['LastOrderNo'] = i-1
|
||||
comicorder['LastOrderID'] = comicorder['SortOrder'][i-1]['ComicID']
|
||||
logger.info("Sucessfully ordered " + str(i-1) + " series in your watchlist.")
|
||||
return comicorder
|
||||
elif sequence == 'update':
|
||||
mylar.COMICSORT['LastOrderNo'] = i-1
|
||||
mylar.COMICSORT['LastOrderID'] = mylar.COMICSORT['SortOrder'][i-1]['ComicID']
|
||||
mylar.COMICSORT['SortOrder'] = comicorderlist
|
||||
print ("i:" + str(i))
|
||||
if i == 0:
|
||||
placemnt = 1
|
||||
else:
|
||||
placemnt = int(i-1)
|
||||
mylar.COMICSORT['LastOrderNo'] = placemnt
|
||||
mylar.COMICSORT['LastOrderID'] = mylar.COMICSORT['SortOrder'][placemnt]['ComicID']
|
||||
return
|
||||
else:
|
||||
# for new series adds, we already know the comicid, so we set the sortorder to an abnormally high #
|
||||
|
|
|
@ -76,6 +76,11 @@ class WebInterface(object):
|
|||
lastno = mylar.COMICSORT['LastOrderNo']
|
||||
lastid = mylar.COMICSORT['LastOrderID']
|
||||
series = {}
|
||||
if skipno == 0:
|
||||
#it's a blank db, let's just null the values and go.
|
||||
series['Current'] = None
|
||||
series['Previous'] = None
|
||||
series['Next'] = None
|
||||
i = 0
|
||||
while (i < skipno):
|
||||
cskip = mylar.COMICSORT['SortOrder'][i]
|
||||
|
|
Loading…
Reference in New Issue