mirror of https://gitlab.com/bashrc2/epicyon
Improve archiving by extracting status code
parent
aaacd78d81
commit
0710f3d38a
19
posts.py
19
posts.py
|
@ -1910,11 +1910,28 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
|
||||||
if not os.path.isdir(archiveDir):
|
if not os.path.isdir(archiveDir):
|
||||||
os.mkdir(archiveDir)
|
os.mkdir(archiveDir)
|
||||||
boxDir = createPersonDir(nickname,domain,baseDir,boxname)
|
boxDir = createPersonDir(nickname,domain,baseDir,boxname)
|
||||||
postsInBox=sorted(os.listdir(boxDir), reverse=False)
|
postsInBox=os.listdir(boxDir)
|
||||||
noOfPosts=len(postsInBox)
|
noOfPosts=len(postsInBox)
|
||||||
if noOfPosts<=maxPostsInBox:
|
if noOfPosts<=maxPostsInBox:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
postsInBoxDict={}
|
||||||
|
postsCtr=0
|
||||||
|
for postFilename in postsInBox:
|
||||||
|
if not postFilename.endswith('.json'):
|
||||||
|
continue
|
||||||
|
# extract the status number
|
||||||
|
statusNumber=getStatusNumberFromPostFilename(postFilename)
|
||||||
|
if statusNumber:
|
||||||
|
postsInBoxDict[statusNumber]=os.path.join(boxDir, postFilename)
|
||||||
|
postsCtr+=1
|
||||||
|
|
||||||
|
noOfPosts=postsCtr
|
||||||
|
if noOfPosts<=maxPostsInBox:
|
||||||
|
return
|
||||||
|
# sort the list in ascending order of date
|
||||||
|
postsInBox=OrderedDict(sorted(postsInBoxDict.items(),reverse=False))
|
||||||
|
|
||||||
for postFilename in postsInBox:
|
for postFilename in postsInBox:
|
||||||
filePath = os.path.join(boxDir, postFilename)
|
filePath = os.path.join(boxDir, postFilename)
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
|
|
Loading…
Reference in New Issue