mirror of https://gitlab.com/bashrc2/epicyon
Exception handling when deleting files
This can fail if a file is manually deleted or deleted in another threadmerge-requests/30/head
parent
851accdb3e
commit
3a94d7fb41
19
blocking.py
19
blocking.py
|
@ -514,7 +514,10 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
with open(postFilename + '.muted', 'w+') as muteFile:
|
with open(postFilename + '.muted', 'w+') as muteFile:
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
|
@ -550,7 +553,10 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
muteFilename = postFilename + '.muted'
|
muteFilename = postFilename + '.muted'
|
||||||
if os.path.isfile(muteFilename):
|
if os.path.isfile(muteFilename):
|
||||||
|
try:
|
||||||
os.remove(muteFilename)
|
os.remove(muteFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
print('UNMUTE: ' + muteFilename + ' file removed')
|
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||||
|
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
|
@ -588,7 +594,10 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as unmuted
|
# if the post is in the recent posts cache then mark it as unmuted
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
|
@ -740,7 +749,10 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
if not enabled:
|
if not enabled:
|
||||||
# remove instance allow list
|
# remove instance allow list
|
||||||
if os.path.isfile(allowFilename):
|
if os.path.isfile(allowFilename):
|
||||||
|
try:
|
||||||
os.remove(allowFilename)
|
os.remove(allowFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
print('Broch mode turned off')
|
print('Broch mode turned off')
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowFilename):
|
if os.path.isfile(allowFilename):
|
||||||
|
@ -799,11 +811,14 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
||||||
currTime = datetime.datetime.utcnow()
|
currTime = datetime.datetime.utcnow()
|
||||||
daysSinceBroch = (currTime - modifiedDate).days
|
daysSinceBroch = (currTime - modifiedDate).days
|
||||||
if daysSinceBroch >= lapseDays:
|
if daysSinceBroch >= lapseDays:
|
||||||
|
removed = False
|
||||||
try:
|
try:
|
||||||
os.remove(allowFilename)
|
os.remove(allowFilename)
|
||||||
|
removed = True
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
if removed:
|
||||||
setConfigParam(baseDir, "brochMode", False)
|
setConfigParam(baseDir, "brochMode", False)
|
||||||
print('Broch mode has elapsed')
|
print('Broch mode has elapsed')
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
|
||||||
pass
|
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -47,7 +47,10 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
domain, postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
# remove from the index
|
# remove from the index
|
||||||
|
@ -152,7 +155,10 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
domain, postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
|
|
|
@ -93,7 +93,10 @@ def updateHashtagCategories(baseDir: str) -> None:
|
||||||
hashtagCategories = getHashtagCategories(baseDir)
|
hashtagCategories = getHashtagCategories(baseDir)
|
||||||
if not hashtagCategories:
|
if not hashtagCategories:
|
||||||
if os.path.isfile(categoryListFilename):
|
if os.path.isfile(categoryListFilename):
|
||||||
|
try:
|
||||||
os.remove(categoryListFilename)
|
os.remove(categoryListFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
categoryList = []
|
categoryList = []
|
||||||
|
|
|
@ -938,9 +938,15 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
for ex in extensionTypes:
|
for ex in extensionTypes:
|
||||||
possibleOtherFormat = filenameBase + '.' + ex
|
possibleOtherFormat = filenameBase + '.' + ex
|
||||||
if os.path.isfile(possibleOtherFormat):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(filenameBase):
|
if os.path.isfile(filenameBase):
|
||||||
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: No media found within POST')
|
print('DEBUG: No media found within POST')
|
||||||
|
@ -1006,7 +1012,10 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
detectedExtension, '.' +
|
detectedExtension, '.' +
|
||||||
ex)
|
ex)
|
||||||
if os.path.isfile(possibleOtherFormat):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
with open(filename, 'wb') as fp:
|
with open(filename, 'wb') as fp:
|
||||||
fp.write(mediaBytes[startPos:])
|
fp.write(mediaBytes[startPos:])
|
||||||
|
|
93
daemon.py
93
daemon.py
|
@ -488,7 +488,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
postJsonObject)
|
postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(postJsonObject,
|
removePostFromCache(postJsonObject,
|
||||||
self.server.recentPostsCache)
|
self.server.recentPostsCache)
|
||||||
|
@ -2256,7 +2259,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newswireBlockedFilename = accountDir + '/.nonewswire'
|
newswireBlockedFilename = accountDir + '/.nonewswire'
|
||||||
if postsToNews == 'on':
|
if postsToNews == 'on':
|
||||||
if os.path.isfile(newswireBlockedFilename):
|
if os.path.isfile(newswireBlockedFilename):
|
||||||
|
try:
|
||||||
os.remove(newswireBlockedFilename)
|
os.remove(newswireBlockedFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
|
@ -2291,7 +2297,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
featuresBlockedFilename = accountDir + '/.nofeatures'
|
featuresBlockedFilename = accountDir + '/.nofeatures'
|
||||||
if postsToFeatures == 'on':
|
if postsToFeatures == 'on':
|
||||||
if os.path.isfile(featuresBlockedFilename):
|
if os.path.isfile(featuresBlockedFilename):
|
||||||
|
try:
|
||||||
os.remove(featuresBlockedFilename)
|
os.remove(featuresBlockedFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
|
@ -2326,7 +2335,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newswireModFilename = accountDir + '/.newswiremoderated'
|
newswireModFilename = accountDir + '/.newswiremoderated'
|
||||||
if modPostsToNews != 'on':
|
if modPostsToNews != 'on':
|
||||||
if os.path.isfile(newswireModFilename):
|
if os.path.isfile(newswireModFilename):
|
||||||
|
try:
|
||||||
os.remove(newswireModFilename)
|
os.remove(newswireModFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
nwFilename = newswireModFilename
|
nwFilename = newswireModFilename
|
||||||
|
@ -3739,7 +3751,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
linksFile.write(linksStr)
|
linksFile.write(linksStr)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(linksFilename):
|
if os.path.isfile(linksFilename):
|
||||||
|
try:
|
||||||
os.remove(linksFilename)
|
os.remove(linksFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
adminNickname = \
|
adminNickname = \
|
||||||
getConfigParam(baseDir, 'admin')
|
getConfigParam(baseDir, 'admin')
|
||||||
|
@ -3752,7 +3767,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aboutFile.write(aboutStr)
|
aboutFile.write(aboutStr)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(aboutFilename):
|
if os.path.isfile(aboutFilename):
|
||||||
|
try:
|
||||||
os.remove(aboutFilename)
|
os.remove(aboutFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
if fields.get('editedTOS'):
|
if fields.get('editedTOS'):
|
||||||
TOSStr = fields['editedTOS']
|
TOSStr = fields['editedTOS']
|
||||||
|
@ -3762,7 +3780,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
TOSFile.write(TOSStr)
|
TOSFile.write(TOSStr)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(TOSFilename):
|
if os.path.isfile(TOSFilename):
|
||||||
|
try:
|
||||||
os.remove(TOSFilename)
|
os.remove(TOSFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
||||||
|
@ -3860,7 +3881,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
categoryFilename = baseDir + '/tags/' + hashtag + '.category'
|
categoryFilename = baseDir + '/tags/' + hashtag + '.category'
|
||||||
if os.path.isfile(categoryFilename):
|
if os.path.isfile(categoryFilename):
|
||||||
|
try:
|
||||||
os.remove(categoryFilename)
|
os.remove(categoryFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(tagScreenStr,
|
self._redirect_headers(tagScreenStr,
|
||||||
|
@ -3938,7 +3962,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newswireFile.write(newswireStr)
|
newswireFile.write(newswireStr)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswireFilename):
|
||||||
|
try:
|
||||||
os.remove(newswireFilename)
|
os.remove(newswireFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save filtered words list for the newswire
|
# save filtered words list for the newswire
|
||||||
filterNewswireFilename = \
|
filterNewswireFilename = \
|
||||||
|
@ -3949,7 +3976,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
filterfile.write(fields['filteredWordsNewswire'])
|
filterfile.write(fields['filteredWordsNewswire'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filterNewswireFilename):
|
if os.path.isfile(filterNewswireFilename):
|
||||||
|
try:
|
||||||
os.remove(filterNewswireFilename)
|
os.remove(filterNewswireFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save news tagging rules
|
# save news tagging rules
|
||||||
hashtagRulesFilename = \
|
hashtagRulesFilename = \
|
||||||
|
@ -3959,7 +3989,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
rulesfile.write(fields['hashtagRulesList'])
|
rulesfile.write(fields['hashtagRulesList'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(hashtagRulesFilename):
|
if os.path.isfile(hashtagRulesFilename):
|
||||||
|
try:
|
||||||
os.remove(hashtagRulesFilename)
|
os.remove(hashtagRulesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
||||||
if fields.get('trustedNewswire'):
|
if fields.get('trustedNewswire'):
|
||||||
|
@ -3970,7 +4003,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
trustFile.write(newswireTrusted)
|
trustFile.write(newswireTrusted)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireTrustedFilename):
|
if os.path.isfile(newswireTrustedFilename):
|
||||||
|
try:
|
||||||
os.remove(newswireTrustedFilename)
|
os.remove(newswireTrustedFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
||||||
|
@ -3995,7 +4031,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
||||||
# remove any existing citations file
|
# remove any existing citations file
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
if newswire and \
|
if newswire and \
|
||||||
' boundary=' in self.headers['Content-type']:
|
' boundary=' in self.headers['Content-type']:
|
||||||
|
@ -4297,7 +4336,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
baseDir + '/imports/newtheme.zip'
|
baseDir + '/imports/newtheme.zip'
|
||||||
if os.path.isfile(filenameBase):
|
if os.path.isfile(filenameBase):
|
||||||
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
acctDir(baseDir, nickname, domain) + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
|
@ -5334,14 +5376,20 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
for ext in fontExt:
|
for ext in fontExt:
|
||||||
if os.path.isfile(baseDir +
|
if os.path.isfile(baseDir +
|
||||||
'/fonts/custom.' + ext):
|
'/fonts/custom.' + ext):
|
||||||
|
try:
|
||||||
os.remove(baseDir +
|
os.remove(baseDir +
|
||||||
'/fonts/custom.' + ext)
|
'/fonts/custom.' + ext)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(baseDir +
|
if os.path.isfile(baseDir +
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
'.etag'):
|
'.etag'):
|
||||||
|
try:
|
||||||
os.remove(baseDir +
|
os.remove(baseDir +
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
'.etag')
|
'.etag')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
currTheme = getTheme(baseDir)
|
currTheme = getTheme(baseDir)
|
||||||
if currTheme:
|
if currTheme:
|
||||||
self.server.themeName = currTheme
|
self.server.themeName = currTheme
|
||||||
|
@ -5389,7 +5437,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
fFile.write('\n')
|
fFile.write('\n')
|
||||||
if not followDMsActive:
|
if not followDMsActive:
|
||||||
if os.path.isfile(followDMsFilename):
|
if os.path.isfile(followDMsFilename):
|
||||||
|
try:
|
||||||
os.remove(followDMsFilename)
|
os.remove(followDMsFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# remove Twitter retweets
|
# remove Twitter retweets
|
||||||
removeTwitterFilename = \
|
removeTwitterFilename = \
|
||||||
|
@ -5404,7 +5455,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
if not removeTwitterActive:
|
if not removeTwitterActive:
|
||||||
if os.path.isfile(removeTwitterFilename):
|
if os.path.isfile(removeTwitterFilename):
|
||||||
|
try:
|
||||||
os.remove(removeTwitterFilename)
|
os.remove(removeTwitterFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# hide Like button
|
# hide Like button
|
||||||
hideLikeButtonFile = \
|
hideLikeButtonFile = \
|
||||||
|
@ -5421,10 +5475,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
# remove notify likes selection
|
# remove notify likes selection
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if not hideLikeButtonActive:
|
if not hideLikeButtonActive:
|
||||||
if os.path.isfile(hideLikeButtonFile):
|
if os.path.isfile(hideLikeButtonFile):
|
||||||
|
try:
|
||||||
os.remove(hideLikeButtonFile)
|
os.remove(hideLikeButtonFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# notify about new Likes
|
# notify about new Likes
|
||||||
if onFinalWelcomeScreen:
|
if onFinalWelcomeScreen:
|
||||||
|
@ -5442,7 +5502,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
rFile.write('\n')
|
rFile.write('\n')
|
||||||
if not notifyLikesActive:
|
if not notifyLikesActive:
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# this account is a bot
|
# this account is a bot
|
||||||
if fields.get('isBot'):
|
if fields.get('isBot'):
|
||||||
|
@ -5501,7 +5564,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
filterfile.write(fields['filteredWords'])
|
filterfile.write(fields['filteredWords'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filterFilename):
|
if os.path.isfile(filterFilename):
|
||||||
|
try:
|
||||||
os.remove(filterFilename)
|
os.remove(filterFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# word replacements
|
# word replacements
|
||||||
switchFilename = \
|
switchFilename = \
|
||||||
|
@ -5512,7 +5578,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
switchfile.write(fields['switchWords'])
|
switchfile.write(fields['switchWords'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(switchFilename):
|
if os.path.isfile(switchFilename):
|
||||||
|
try:
|
||||||
os.remove(switchFilename)
|
os.remove(switchFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# autogenerated tags
|
# autogenerated tags
|
||||||
autoTagsFilename = \
|
autoTagsFilename = \
|
||||||
|
@ -5523,7 +5592,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
autoTagsFile.write(fields['autoTags'])
|
autoTagsFile.write(fields['autoTags'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(autoTagsFilename):
|
if os.path.isfile(autoTagsFilename):
|
||||||
|
try:
|
||||||
os.remove(autoTagsFilename)
|
os.remove(autoTagsFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# autogenerated content warnings
|
# autogenerated content warnings
|
||||||
autoCWFilename = \
|
autoCWFilename = \
|
||||||
|
@ -5534,7 +5606,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
autoCWFile.write(fields['autoCW'])
|
autoCWFile.write(fields['autoCW'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(autoCWFilename):
|
if os.path.isfile(autoCWFilename):
|
||||||
|
try:
|
||||||
os.remove(autoCWFilename)
|
os.remove(autoCWFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save blocked accounts list
|
# save blocked accounts list
|
||||||
blockedFilename = \
|
blockedFilename = \
|
||||||
|
@ -5545,7 +5620,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
blockedfile.write(fields['blocked'])
|
blockedfile.write(fields['blocked'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(blockedFilename):
|
if os.path.isfile(blockedFilename):
|
||||||
|
try:
|
||||||
os.remove(blockedFilename)
|
os.remove(blockedFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# Save DM allowed instances list.
|
# Save DM allowed instances list.
|
||||||
# The allow list for incoming DMs,
|
# The allow list for incoming DMs,
|
||||||
|
@ -5558,7 +5636,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aFile.write(fields['dmAllowedInstances'])
|
aFile.write(fields['dmAllowedInstances'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(dmAllowedInstancesFilename):
|
if os.path.isfile(dmAllowedInstancesFilename):
|
||||||
|
try:
|
||||||
os.remove(dmAllowedInstancesFilename)
|
os.remove(dmAllowedInstancesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save allowed instances list
|
# save allowed instances list
|
||||||
# This is the account level allow list
|
# This is the account level allow list
|
||||||
|
@ -5570,7 +5651,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aFile.write(fields['allowedInstances'])
|
aFile.write(fields['allowedInstances'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowedInstancesFilename):
|
if os.path.isfile(allowedInstancesFilename):
|
||||||
|
try:
|
||||||
os.remove(allowedInstancesFilename)
|
os.remove(allowedInstancesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save blocked user agents
|
# save blocked user agents
|
||||||
# This is admin lebel and global to the instance
|
# This is admin lebel and global to the instance
|
||||||
|
@ -5615,7 +5699,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.peertubeInstances.append(url)
|
self.server.peertubeInstances.append(url)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(peertubeInstancesFile):
|
if os.path.isfile(peertubeInstancesFile):
|
||||||
|
try:
|
||||||
os.remove(peertubeInstancesFile)
|
os.remove(peertubeInstancesFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
self.server.peertubeInstances.clear()
|
self.server.peertubeInstances.clear()
|
||||||
|
|
||||||
# save git project names list
|
# save git project names list
|
||||||
|
@ -5627,7 +5714,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aFile.write(fields['gitProjects'].lower())
|
aFile.write(fields['gitProjects'].lower())
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(gitProjectsFilename):
|
if os.path.isfile(gitProjectsFilename):
|
||||||
|
try:
|
||||||
os.remove(gitProjectsFilename)
|
os.remove(gitProjectsFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# save actor json file within accounts
|
# save actor json file within accounts
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
|
@ -15025,7 +15115,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.lowBandwidth)
|
self.server.lowBandwidth)
|
||||||
if filename:
|
if filename:
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
self.postToNickname = nickname
|
self.postToNickname = nickname
|
||||||
return 1
|
return 1
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -44,7 +44,10 @@ def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
||||||
personDir = acctDir(baseDir, nickname, domain)
|
personDir = acctDir(baseDir, nickname, domain)
|
||||||
deviceFilename = personDir + '/devices/' + deviceId + '.json'
|
deviceFilename = personDir + '/devices/' + deviceId + '.json'
|
||||||
if os.path.isfile(deviceFilename):
|
if os.path.isfile(deviceFilename):
|
||||||
|
try:
|
||||||
os.remove(deviceFilename)
|
os.remove(deviceFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,10 @@ def clearFollows(baseDir: str, nickname: str, domain: str,
|
||||||
os.mkdir(baseDir + '/accounts/' + handle)
|
os.mkdir(baseDir + '/accounts/' + handle)
|
||||||
filename = baseDir + '/accounts/' + handle + '/' + followFile
|
filename = baseDir + '/accounts/' + handle + '/' + followFile
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def clearFollowers(baseDir: str, nickname: str, domain: str) -> None:
|
def clearFollowers(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
|
36
inbox.py
36
inbox.py
|
@ -821,7 +821,10 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, messageJson: {},
|
||||||
getCachedPostFilename(baseDir, nickname, domain, messageJson)
|
getCachedPostFilename(baseDir, nickname, domain, messageJson)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(messageJson, recentPostsCache)
|
removePostFromCache(messageJson, recentPostsCache)
|
||||||
|
|
||||||
|
@ -1583,7 +1586,10 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
if domain not in messageJson['object'] and notInOnion:
|
if domain not in messageJson['object'] and notInOnion:
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
# if the announce can't be downloaded then remove it
|
# if the announce can't be downloaded then remove it
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Announce post downloaded for ' +
|
print('DEBUG: Announce post downloaded for ' +
|
||||||
|
@ -1693,7 +1699,10 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
||||||
undoAnnounceCollectionEntry(recentPostsCache, baseDir, postFilename,
|
undoAnnounceCollectionEntry(recentPostsCache, baseDir, postFilename,
|
||||||
messageJson['actor'], domain, debug)
|
messageJson['actor'], domain, debug)
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -3276,7 +3285,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if debug:
|
if debug:
|
||||||
print('Queue: public key could not be obtained from ' + keyId)
|
print('Queue: public key could not be obtained from ' + keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3324,7 +3336,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
|
|
||||||
if httpSignatureFailed or verifyAllSignatures:
|
if httpSignatureFailed or verifyAllSignatures:
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3341,7 +3356,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
print('WARN: jsonld inbox signature check failed ' +
|
print('WARN: jsonld inbox signature check failed ' +
|
||||||
keyId)
|
keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3367,7 +3385,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
debug):
|
debug):
|
||||||
print('Queue: Undo accepted from ' + keyId)
|
print('Queue: Undo accepted from ' + keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3385,7 +3406,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
maxFollowers, onionDomain,
|
maxFollowers, onionDomain,
|
||||||
signingPrivateKeyPem):
|
signingPrivateKeyPem):
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
print('Queue: Follow activity for ' + keyId +
|
print('Queue: Follow activity for ' + keyId +
|
||||||
|
@ -3403,7 +3427,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
federationList, debug):
|
federationList, debug):
|
||||||
print('Queue: Accept/Reject received from ' + keyId)
|
print('Queue: Accept/Reject received from ' + keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3421,7 +3448,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if debug:
|
if debug:
|
||||||
print('Queue: Update accepted from ' + keyId)
|
print('Queue: Update accepted from ' + keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3436,7 +3466,10 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
print('Queue: no recipients were resolved ' +
|
print('Queue: no recipients were resolved ' +
|
||||||
'for post arriving in inbox')
|
'for post arriving in inbox')
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -3506,6 +3539,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
pprint(queueJson['post'])
|
pprint(queueJson['post'])
|
||||||
print('Queue: Queue post accepted')
|
print('Queue: Queue post accepted')
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
3
like.py
3
like.py
|
@ -431,7 +431,10 @@ def updateLikesCollection(recentPostsCache: {},
|
||||||
domain, postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -222,6 +222,12 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
# remove the .follow file
|
# remove the .follow file
|
||||||
if followActivityfilename:
|
if followActivityfilename:
|
||||||
if os.path.isfile(followActivityfilename):
|
if os.path.isfile(followActivityfilename):
|
||||||
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
os.remove(approveFollowsFilename + '.new')
|
os.remove(approveFollowsFilename + '.new')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
|
@ -702,7 +702,10 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
blog['object']['arrived'])
|
blog['object']['arrived'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filename + '.arrived'):
|
if os.path.isfile(filename + '.arrived'):
|
||||||
|
try:
|
||||||
os.remove(filename + '.arrived')
|
os.remove(filename + '.arrived')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# setting the url here links to the activitypub object
|
# setting the url here links to the activitypub object
|
||||||
# stored locally
|
# stored locally
|
||||||
|
|
|
@ -1028,7 +1028,10 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
||||||
else:
|
else:
|
||||||
# remove the file if there is nothing to moderate
|
# remove the file if there is nothing to moderate
|
||||||
if os.path.isfile(newswireModerationFilename):
|
if os.path.isfile(newswireModerationFilename):
|
||||||
|
try:
|
||||||
os.remove(newswireModerationFilename)
|
os.remove(newswireModerationFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def getDictFromNewswire(session, baseDir: str, domain: str,
|
def getDictFromNewswire(session, baseDir: str, domain: str,
|
||||||
|
|
|
@ -390,7 +390,10 @@ def postMessageToOutbox(session, translate: {},
|
||||||
baseDir + '/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
postToNickname + '@' + domain + '/.citations.txt'
|
postToNickname + '@' + domain + '/.citations.txt'
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# The following activity types get added to the index files
|
# The following activity types get added to the index files
|
||||||
indexedActivities = (
|
indexedActivities = (
|
||||||
|
|
21
person.py
21
person.py
|
@ -919,10 +919,16 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
|
||||||
saltFilename = acctDir(baseDir, nickname, domain) + '/.salt'
|
saltFilename = acctDir(baseDir, nickname, domain) + '/.salt'
|
||||||
if os.path.isfile(saltFilename):
|
if os.path.isfile(saltFilename):
|
||||||
|
try:
|
||||||
os.remove(saltFilename)
|
os.remove(saltFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
||||||
if os.path.isfile(tokenFilename):
|
if os.path.isfile(tokenFilename):
|
||||||
|
try:
|
||||||
os.remove(tokenFilename)
|
os.remove(tokenFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||||
if os.path.isfile(suspendedFilename):
|
if os.path.isfile(suspendedFilename):
|
||||||
|
@ -1025,17 +1031,32 @@ def removeAccount(baseDir: str, nickname: str,
|
||||||
if os.path.isdir(baseDir + '/accounts/' + handle):
|
if os.path.isdir(baseDir + '/accounts/' + handle):
|
||||||
shutil.rmtree(baseDir + '/accounts/' + handle)
|
shutil.rmtree(baseDir + '/accounts/' + handle)
|
||||||
if os.path.isfile(baseDir + '/accounts/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/accounts/' + handle + '.json'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/accounts/' + handle + '.json')
|
os.remove(baseDir + '/accounts/' + handle + '.json')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(baseDir + '/wfendpoints/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/wfendpoints/' + handle + '.json'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/wfendpoints/' + handle + '.json')
|
os.remove(baseDir + '/wfendpoints/' + handle + '.json')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(baseDir + '/keys/private/' + handle + '.key'):
|
if os.path.isfile(baseDir + '/keys/private/' + handle + '.key'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/keys/private/' + handle + '.key')
|
os.remove(baseDir + '/keys/private/' + handle + '.key')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(baseDir + '/keys/public/' + handle + '.pem'):
|
if os.path.isfile(baseDir + '/keys/public/' + handle + '.pem'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/keys/public/' + handle + '.pem')
|
os.remove(baseDir + '/keys/public/' + handle + '.pem')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
if os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
||||||
shutil.rmtree(baseDir + '/sharefiles/' + nickname)
|
shutil.rmtree(baseDir + '/sharefiles/' + nickname)
|
||||||
if os.path.isfile(baseDir + '/wfdeactivated/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/wfdeactivated/' + handle + '.json'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
|
os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
|
if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
|
||||||
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname)
|
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname)
|
||||||
|
|
||||||
|
|
6
posts.py
6
posts.py
|
@ -1470,7 +1470,10 @@ def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
|
try:
|
||||||
os.remove(pinnedFilename)
|
os.remove(pinnedFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
||||||
|
@ -3766,7 +3769,10 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
||||||
postCacheFilename = \
|
postCacheFilename = \
|
||||||
os.path.join(postCacheDir, postFilename).replace('.json', '.html')
|
os.path.join(postCacheDir, postFilename).replace('.json', '.html')
|
||||||
if os.path.isfile(postCacheFilename):
|
if os.path.isfile(postCacheFilename):
|
||||||
|
try:
|
||||||
os.remove(postCacheFilename)
|
os.remove(postCacheFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
noOfPosts -= 1
|
noOfPosts -= 1
|
||||||
removeCtr += 1
|
removeCtr += 1
|
||||||
|
|
12
schedule.py
12
schedule.py
|
@ -46,7 +46,10 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
if deleteSchedulePost:
|
if deleteSchedulePost:
|
||||||
# delete extraneous scheduled posts
|
# delete extraneous scheduled posts
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
continue
|
continue
|
||||||
# create the new index file
|
# create the new index file
|
||||||
indexLines.append(line)
|
indexLines.append(line)
|
||||||
|
@ -122,7 +125,10 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
httpd.maxLikeCount,
|
httpd.maxLikeCount,
|
||||||
httpd.maxRecentPosts):
|
httpd.maxRecentPosts):
|
||||||
indexLines.remove(line)
|
indexLines.remove(line)
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# move to the outbox
|
# move to the outbox
|
||||||
|
@ -190,7 +196,10 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
scheduleIndexFilename = \
|
scheduleIndexFilename = \
|
||||||
acctDir(baseDir, nickname, domain) + '/schedule.index'
|
acctDir(baseDir, nickname, domain) + '/schedule.index'
|
||||||
if os.path.isfile(scheduleIndexFilename):
|
if os.path.isfile(scheduleIndexFilename):
|
||||||
|
try:
|
||||||
os.remove(scheduleIndexFilename)
|
os.remove(scheduleIndexFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
# remove the scheduled posts
|
# remove the scheduled posts
|
||||||
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
||||||
if not os.path.isdir(scheduledDir):
|
if not os.path.isdir(scheduledDir):
|
||||||
|
@ -199,6 +208,9 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
filePath = os.path.join(scheduledDir, scheduledPostFilename)
|
filePath = os.path.join(scheduledDir, scheduledPostFilename)
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
|
try:
|
||||||
os.remove(filePath)
|
os.remove(filePath)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
|
@ -142,7 +142,10 @@ def removeSharedItem(baseDir: str, nickname: str, domain: str,
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
if sharesJson[itemID]['imageUrl'].endswith('.' + ext):
|
if sharesJson[itemID]['imageUrl'].endswith('.' + ext):
|
||||||
if os.path.isfile(itemIDfile + '.' + ext):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
# remove the item itself
|
# remove the item itself
|
||||||
del sharesJson[itemID]
|
del sharesJson[itemID]
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
@ -350,7 +353,10 @@ def addShare(baseDir: str,
|
||||||
imageFilename, itemIDfile + '.' + ext,
|
imageFilename, itemIDfile + '.' + ext,
|
||||||
city)
|
city)
|
||||||
if moveImage:
|
if moveImage:
|
||||||
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
imageUrl = \
|
imageUrl = \
|
||||||
httpPrefix + '://' + domainFull + \
|
httpPrefix + '://' + domainFull + \
|
||||||
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
|
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
|
||||||
|
@ -419,7 +425,10 @@ def _expireSharesForAccount(baseDir: str, nickname: str, domain: str,
|
||||||
formats = getImageExtensions()
|
formats = getImageExtensions()
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
if os.path.isfile(itemIDfile + '.' + ext):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
|
||||||
|
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -3197,7 +3197,10 @@ def _testJsonString() -> None:
|
||||||
assert receivedJson['content'] == messageStr
|
assert receivedJson['content'] == messageStr
|
||||||
encodedStr = json.dumps(testJson, ensure_ascii=False)
|
encodedStr = json.dumps(testJson, ensure_ascii=False)
|
||||||
assert messageStr in encodedStr
|
assert messageStr in encodedStr
|
||||||
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _testSaveLoadJson():
|
def _testSaveLoadJson():
|
||||||
|
@ -3208,7 +3211,10 @@ def _testSaveLoadJson():
|
||||||
}
|
}
|
||||||
testFilename = '.epicyon_tests_testSaveLoadJson.json'
|
testFilename = '.epicyon_tests_testSaveLoadJson.json'
|
||||||
if os.path.isfile(testFilename):
|
if os.path.isfile(testFilename):
|
||||||
|
try:
|
||||||
os.remove(testFilename)
|
os.remove(testFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
assert saveJson(testJson, testFilename)
|
assert saveJson(testJson, testFilename)
|
||||||
assert os.path.isfile(testFilename)
|
assert os.path.isfile(testFilename)
|
||||||
testLoadJson = loadJson(testFilename)
|
testLoadJson = loadJson(testFilename)
|
||||||
|
@ -3217,7 +3223,10 @@ def _testSaveLoadJson():
|
||||||
assert testLoadJson.get('param2')
|
assert testLoadJson.get('param2')
|
||||||
assert testLoadJson['param1'] == 3
|
assert testLoadJson['param1'] == 3
|
||||||
assert testLoadJson['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
assert testLoadJson['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
||||||
|
try:
|
||||||
os.remove(testFilename)
|
os.remove(testFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _testTheme():
|
def _testTheme():
|
||||||
|
|
21
theme.py
21
theme.py
|
@ -83,7 +83,10 @@ def exportTheme(baseDir: str, theme: str) -> bool:
|
||||||
os.mkdir(baseDir + '/exports')
|
os.mkdir(baseDir + '/exports')
|
||||||
exportFilename = baseDir + '/exports/' + theme + '.zip'
|
exportFilename = baseDir + '/exports/' + theme + '.zip'
|
||||||
if os.path.isfile(exportFilename):
|
if os.path.isfile(exportFilename):
|
||||||
|
try:
|
||||||
os.remove(exportFilename)
|
os.remove(exportFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
@ -250,7 +253,10 @@ def _removeTheme(baseDir: str):
|
||||||
themeFiles = _getThemeFiles()
|
themeFiles = _getThemeFiles()
|
||||||
for filename in themeFiles:
|
for filename in themeFiles:
|
||||||
if os.path.isfile(baseDir + '/' + filename):
|
if os.path.isfile(baseDir + '/' + filename):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/' + filename)
|
os.remove(baseDir + '/' + filename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def setCSSparam(css: str, param: str, value: str) -> str:
|
def setCSSparam(css: str, param: str, value: str) -> str:
|
||||||
|
@ -432,7 +438,10 @@ def disableGrayscale(baseDir: str) -> None:
|
||||||
cssfile.write(css)
|
cssfile.write(css)
|
||||||
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
grayscaleFilename = baseDir + '/accounts/.grayscale'
|
||||||
if os.path.isfile(grayscaleFilename):
|
if os.path.isfile(grayscaleFilename):
|
||||||
|
try:
|
||||||
os.remove(grayscaleFilename)
|
os.remove(grayscaleFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _setCustomFont(baseDir: str):
|
def _setCustomFont(baseDir: str):
|
||||||
|
@ -587,7 +596,10 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
||||||
textModeBannerFilename = \
|
textModeBannerFilename = \
|
||||||
baseDir + '/theme/' + name + '/banner.txt'
|
baseDir + '/theme/' + name + '/banner.txt'
|
||||||
if os.path.isfile(baseDir + '/accounts/banner.txt'):
|
if os.path.isfile(baseDir + '/accounts/banner.txt'):
|
||||||
|
try:
|
||||||
os.remove(baseDir + '/accounts/banner.txt')
|
os.remove(baseDir + '/accounts/banner.txt')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isfile(textModeBannerFilename):
|
if os.path.isfile(textModeBannerFilename):
|
||||||
try:
|
try:
|
||||||
copyfile(textModeBannerFilename,
|
copyfile(textModeBannerFilename,
|
||||||
|
@ -684,7 +696,10 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(accountDir +
|
if os.path.isfile(accountDir +
|
||||||
'/left_col_image.png'):
|
'/left_col_image.png'):
|
||||||
|
try:
|
||||||
os.remove(accountDir + '/left_col_image.png')
|
os.remove(accountDir + '/left_col_image.png')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
@ -696,9 +711,12 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(accountDir +
|
if os.path.isfile(accountDir +
|
||||||
'/right_col_image.png'):
|
'/right_col_image.png'):
|
||||||
|
try:
|
||||||
os.remove(accountDir + '/right_col_image.png')
|
os.remove(accountDir + '/right_col_image.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,7 +737,10 @@ def setNewsAvatar(baseDir: str, name: str,
|
||||||
filename = baseDir + '/cache/avatars/' + avatarFilename
|
filename = baseDir + '/cache/avatars/' + avatarFilename
|
||||||
|
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
if os.path.isdir(baseDir + '/cache/avatars'):
|
if os.path.isdir(baseDir + '/cache/avatars'):
|
||||||
copyfile(newFilename, filename)
|
copyfile(newFilename, filename)
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
|
42
utils.py
42
utils.py
|
@ -614,7 +614,10 @@ def removeAvatarFromCache(baseDir: str, actorStr: str) -> None:
|
||||||
avatarFilename = \
|
avatarFilename = \
|
||||||
baseDir + '/cache/avatars/' + actorStr + '.' + extension
|
baseDir + '/cache/avatars/' + actorStr + '.' + extension
|
||||||
if os.path.isfile(avatarFilename):
|
if os.path.isfile(avatarFilename):
|
||||||
|
try:
|
||||||
os.remove(avatarFilename)
|
os.remove(avatarFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def saveJson(jsonObject: {}, filename: str) -> bool:
|
def saveJson(jsonObject: {}, filename: str) -> bool:
|
||||||
|
@ -1318,10 +1321,16 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
||||||
mediaFilename = baseDir + '/' + \
|
mediaFilename = baseDir + '/' + \
|
||||||
attachmentUrl.replace(httpPrefix + '://' + domain + '/', '')
|
attachmentUrl.replace(httpPrefix + '://' + domain + '/', '')
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(mediaFilename):
|
||||||
|
try:
|
||||||
os.remove(mediaFilename)
|
os.remove(mediaFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
etagFilename = mediaFilename + '.etag'
|
etagFilename = mediaFilename + '.etag'
|
||||||
if os.path.isfile(etagFilename):
|
if os.path.isfile(etagFilename):
|
||||||
|
try:
|
||||||
os.remove(etagFilename)
|
os.remove(etagFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
postJson['attachment'] = []
|
postJson['attachment'] = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -1386,7 +1395,10 @@ def _deletePostRemoveReplies(baseDir: str, nickname: str, domain: str,
|
||||||
nickname, domain, replyFile, debug,
|
nickname, domain, replyFile, debug,
|
||||||
recentPostsCache)
|
recentPostsCache)
|
||||||
# remove the replies file
|
# remove the replies file
|
||||||
|
try:
|
||||||
os.remove(repliesFilename)
|
os.remove(repliesFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1442,7 +1454,10 @@ def _deleteCachedHtml(baseDir: str, nickname: str, domain: str,
|
||||||
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
|
@ -1486,7 +1501,10 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
newlines += fileLine
|
newlines += fileLine
|
||||||
if not newlines.strip():
|
if not newlines.strip():
|
||||||
# if there are no lines then remove the hashtag file
|
# if there are no lines then remove the hashtag file
|
||||||
|
try:
|
||||||
os.remove(tagIndexFilename)
|
os.remove(tagIndexFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
# write the new hashtag index without the given post in it
|
# write the new hashtag index without the given post in it
|
||||||
with open(tagIndexFilename, 'w+') as f:
|
with open(tagIndexFilename, 'w+') as f:
|
||||||
|
@ -1521,8 +1539,14 @@ def _deleteConversationPost(baseDir: str, nickname: str, domain: str,
|
||||||
fp.write(conversationStr)
|
fp.write(conversationStr)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(conversationFilename + '.muted'):
|
if os.path.isfile(conversationFilename + '.muted'):
|
||||||
|
try:
|
||||||
os.remove(conversationFilename + '.muted')
|
os.remove(conversationFilename + '.muted')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
os.remove(conversationFilename)
|
os.remove(conversationFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def deletePost(baseDir: str, httpPrefix: str,
|
def deletePost(baseDir: str, httpPrefix: str,
|
||||||
|
@ -1537,7 +1561,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
httpPrefix, postFilename,
|
httpPrefix, postFilename,
|
||||||
recentPostsCache, debug)
|
recentPostsCache, debug)
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
# don't allow deletion of bookmarked posts
|
# don't allow deletion of bookmarked posts
|
||||||
|
@ -1562,7 +1589,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
extFilename = postFilename + '.' + ext
|
extFilename = postFilename + '.' + ext
|
||||||
if os.path.isfile(extFilename):
|
if os.path.isfile(extFilename):
|
||||||
|
try:
|
||||||
os.remove(extFilename)
|
os.remove(extFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# remove cached html version of the post
|
# remove cached html version of the post
|
||||||
_deleteCachedHtml(baseDir, nickname, domain, postJsonObject)
|
_deleteCachedHtml(baseDir, nickname, domain, postJsonObject)
|
||||||
|
@ -1588,7 +1618,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
httpPrefix, postFilename,
|
httpPrefix, postFilename,
|
||||||
recentPostsCache, debug)
|
recentPostsCache, debug)
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def isValidLanguage(text: str) -> bool:
|
def isValidLanguage(text: str) -> bool:
|
||||||
|
@ -2022,7 +2055,10 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
domain, postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
|
@ -2083,7 +2119,10 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
postJsonObject)
|
postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
|
@ -2144,7 +2183,10 @@ def updateAnnounceCollection(recentPostsCache: {},
|
||||||
postJsonObject)
|
postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
|
|
|
@ -110,7 +110,10 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
calendarFile = accountDir + '/.newCalendar'
|
calendarFile = accountDir + '/.newCalendar'
|
||||||
if os.path.isfile(calendarFile):
|
if os.path.isfile(calendarFile):
|
||||||
|
try:
|
||||||
os.remove(calendarFile)
|
os.remove(calendarFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
cssFilename = baseDir + '/epicyon-calendar.css'
|
cssFilename = baseDir + '/epicyon-calendar.css'
|
||||||
if os.path.isfile(baseDir + '/calendar.css'):
|
if os.path.isfile(baseDir + '/calendar.css'):
|
||||||
|
|
|
@ -34,7 +34,10 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||||
minimalFilename = accountDir + '/.notminimal'
|
minimalFilename = accountDir + '/.notminimal'
|
||||||
minimalFileExists = os.path.isfile(minimalFilename)
|
minimalFileExists = os.path.isfile(minimalFilename)
|
||||||
if minimal and minimalFileExists:
|
if minimal and minimalFileExists:
|
||||||
|
try:
|
||||||
os.remove(minimalFilename)
|
os.remove(minimalFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
elif not minimal and not minimalFileExists:
|
elif not minimal and not minimalFileExists:
|
||||||
with open(minimalFilename, 'w+') as fp:
|
with open(minimalFilename, 'w+') as fp:
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
|
|
|
@ -451,7 +451,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if os.path.isfile(dmFile):
|
if os.path.isfile(dmFile):
|
||||||
newDM = True
|
newDM = True
|
||||||
if boxName == 'dm':
|
if boxName == 'dm':
|
||||||
|
try:
|
||||||
os.remove(dmFile)
|
os.remove(dmFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# should the Replies button be highlighted?
|
# should the Replies button be highlighted?
|
||||||
newReply = False
|
newReply = False
|
||||||
|
@ -459,7 +462,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if os.path.isfile(replyFile):
|
if os.path.isfile(replyFile):
|
||||||
newReply = True
|
newReply = True
|
||||||
if boxName == 'tlreplies':
|
if boxName == 'tlreplies':
|
||||||
|
try:
|
||||||
os.remove(replyFile)
|
os.remove(replyFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# should the Shares button be highlighted?
|
# should the Shares button be highlighted?
|
||||||
newShare = False
|
newShare = False
|
||||||
|
@ -467,7 +473,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if os.path.isfile(newShareFile):
|
if os.path.isfile(newShareFile):
|
||||||
newShare = True
|
newShare = True
|
||||||
if boxName == 'tlshares':
|
if boxName == 'tlshares':
|
||||||
|
try:
|
||||||
os.remove(newShareFile)
|
os.remove(newShareFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# should the Wanted button be highlighted?
|
# should the Wanted button be highlighted?
|
||||||
newWanted = False
|
newWanted = False
|
||||||
|
@ -475,7 +484,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if os.path.isfile(newWantedFile):
|
if os.path.isfile(newWantedFile):
|
||||||
newWanted = True
|
newWanted = True
|
||||||
if boxName == 'tlwanted':
|
if boxName == 'tlwanted':
|
||||||
|
try:
|
||||||
os.remove(newWantedFile)
|
os.remove(newWantedFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
# should the Moderation/reports button be highlighted?
|
# should the Moderation/reports button be highlighted?
|
||||||
newReport = False
|
newReport = False
|
||||||
|
@ -483,7 +495,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if os.path.isfile(newReportFile):
|
if os.path.isfile(newReportFile):
|
||||||
newReport = True
|
newReport = True
|
||||||
if boxName == 'moderation':
|
if boxName == 'moderation':
|
||||||
|
try:
|
||||||
os.remove(newReportFile)
|
os.remove(newReportFile)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
separatorStr = ''
|
separatorStr = ''
|
||||||
if boxName != 'tlmedia':
|
if boxName != 'tlmedia':
|
||||||
|
|
|
@ -280,7 +280,10 @@ def updateAvatarImageCache(signingPrivateKeyPem: str,
|
||||||
str(result.status_code))
|
str(result.status_code))
|
||||||
# remove partial download
|
# remove partial download
|
||||||
if os.path.isfile(avatarImageFilename):
|
if os.path.isfile(avatarImageFilename):
|
||||||
|
try:
|
||||||
os.remove(avatarImageFilename)
|
os.remove(avatarImageFilename)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
with open(avatarImageFilename, 'wb') as f:
|
with open(avatarImageFilename, 'wb') as f:
|
||||||
f.write(result.content)
|
f.write(result.content)
|
||||||
|
|
Loading…
Reference in New Issue