mirror of https://gitlab.com/bashrc2/epicyon
Add exception handling for index
parent
5c67ada3bb
commit
53fc839cae
24
inbox.py
24
inbox.py
|
@ -1516,16 +1516,22 @@ def inboxUpdateIndex(baseDir: str,handle: str,destinationFilename: str,debug: bo
|
||||||
if '/'+boxname+'/' in destinationFilename:
|
if '/'+boxname+'/' in destinationFilename:
|
||||||
destinationFilename=destinationFilename.split('/'+boxname+'/')[1]
|
destinationFilename=destinationFilename.split('/'+boxname+'/')[1]
|
||||||
if os.path.isfile(indexFilename):
|
if os.path.isfile(indexFilename):
|
||||||
with open(indexFilename, 'r+') as indexFile:
|
try:
|
||||||
content = indexFile.read()
|
with open(indexFilename, 'r+') as indexFile:
|
||||||
indexFile.seek(0, 0)
|
content = indexFile.read()
|
||||||
indexFile.write(destinationFilename+'\n'+content)
|
indexFile.seek(0, 0)
|
||||||
return True
|
indexFile.write(destinationFilename+'\n'+content)
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
print('Failed to write entry to index '+str(e))
|
||||||
else:
|
else:
|
||||||
indexFile=open(indexFilename,'w+')
|
try:
|
||||||
if indexFile:
|
indexFile=open(indexFilename,'w+')
|
||||||
indexFile.write(destinationFilename+'\n')
|
if indexFile:
|
||||||
indexFile.close()
|
indexFile.write(destinationFilename+'\n')
|
||||||
|
indexFile.close()
|
||||||
|
except Exception as e:
|
||||||
|
print('Failed to write initial entry to index '+str(e))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
5
posts.py
5
posts.py
|
@ -2040,10 +2040,7 @@ def createBoxBase(session,baseDir: str,boxname: str, \
|
||||||
maxPostCtr=(itemsPerPage+3)*pageNumber
|
maxPostCtr=(itemsPerPage+3)*pageNumber
|
||||||
with open(indexFilename, 'r') as indexFile:
|
with open(indexFilename, 'r') as indexFile:
|
||||||
for postFilename in indexFile:
|
for postFilename in indexFile:
|
||||||
statusNumber=getStatusNumberFromPostFilename(postFilename)
|
postsInBox[postsCtr]=os.path.join(boxDir, postFilename.replace('\n',''))
|
||||||
if not statusNumber:
|
|
||||||
continue
|
|
||||||
postsInBox[statusNumber]=os.path.join(boxDir, postFilename.replace('\n',''))
|
|
||||||
postsCtr+=1
|
postsCtr+=1
|
||||||
if maxPostCtr:
|
if maxPostCtr:
|
||||||
if postsCtr>=maxPostCtr:
|
if postsCtr>=maxPostCtr:
|
||||||
|
|
Loading…
Reference in New Issue