Check if hashtag index was modified today

main
Bob Mottram 2020-05-31 13:10:50 +01:00
parent 420d299ec3
commit 05540280d8
1 changed files with 5 additions and 0 deletions

View File

@ -5739,12 +5739,17 @@ def htmlHashTagSwarm(baseDir: str, actor: str) -> str:
tagsFilename = os.path.join(baseDir + '/tags', f) tagsFilename = os.path.join(baseDir + '/tags', f)
if not os.path.isfile(tagsFilename): if not os.path.isfile(tagsFilename):
continue continue
# get last modified datetime
modTimesinceEpoc = os.path.getmtime(tagsFilename) modTimesinceEpoc = os.path.getmtime(tagsFilename)
lastModifiedDate = datetime.fromtimestamp(modTimesinceEpoc) lastModifiedDate = datetime.fromtimestamp(modTimesinceEpoc)
fileDaysSinceEpoch = (lastModifiedDate - datetime(1970, 1, 1)).days fileDaysSinceEpoch = (lastModifiedDate - datetime(1970, 1, 1)).days
# check of the file is too old
if fileDaysSinceEpoch < maxDaysSinceEpoch: if fileDaysSinceEpoch < maxDaysSinceEpoch:
removeHashtags.append(tagsFilename) removeHashtags.append(tagsFilename)
continue continue
# check if the file was last modified today
if fileDaysSinceEpoch != daysSinceEpoch:
continue
hashTagName = f.split('.')[0] hashTagName = f.split('.')[0]
if isBlockedHashtag(baseDir, hashTagName): if isBlockedHashtag(baseDir, hashTagName):