forked from indymedia/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:
|
||||
destinationFilename=destinationFilename.split('/'+boxname+'/')[1]
|
||||
if os.path.isfile(indexFilename):
|
||||
with open(indexFilename, 'r+') as indexFile:
|
||||
content = indexFile.read()
|
||||
indexFile.seek(0, 0)
|
||||
indexFile.write(destinationFilename+'\n'+content)
|
||||
return True
|
||||
try:
|
||||
with open(indexFilename, 'r+') as indexFile:
|
||||
content = indexFile.read()
|
||||
indexFile.seek(0, 0)
|
||||
indexFile.write(destinationFilename+'\n'+content)
|
||||
return True
|
||||
except Exception as e:
|
||||
print('Failed to write entry to index '+str(e))
|
||||
else:
|
||||
indexFile=open(indexFilename,'w+')
|
||||
if indexFile:
|
||||
indexFile.write(destinationFilename+'\n')
|
||||
indexFile.close()
|
||||
try:
|
||||
indexFile=open(indexFilename,'w+')
|
||||
if indexFile:
|
||||
indexFile.write(destinationFilename+'\n')
|
||||
indexFile.close()
|
||||
except Exception as e:
|
||||
print('Failed to write initial entry to index '+str(e))
|
||||
|
||||
return False
|
||||
|
||||
|
|
5
posts.py
5
posts.py
|
@ -2040,10 +2040,7 @@ def createBoxBase(session,baseDir: str,boxname: str, \
|
|||
maxPostCtr=(itemsPerPage+3)*pageNumber
|
||||
with open(indexFilename, 'r') as indexFile:
|
||||
for postFilename in indexFile:
|
||||
statusNumber=getStatusNumberFromPostFilename(postFilename)
|
||||
if not statusNumber:
|
||||
continue
|
||||
postsInBox[statusNumber]=os.path.join(boxDir, postFilename.replace('\n',''))
|
||||
postsInBox[postsCtr]=os.path.join(boxDir, postFilename.replace('\n',''))
|
||||
postsCtr+=1
|
||||
if maxPostCtr:
|
||||
if postsCtr>=maxPostCtr:
|
||||
|
|
Loading…
Reference in New Issue