Skip to content

Commit

Permalink
More aggressive purging of cached images
Browse files Browse the repository at this point in the history
Purge when 1 hr old, not 1 day.
  • Loading branch information
richardbuckle committed Dec 12, 2018
1 parent 13e6b87 commit ce2aa99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion purgeConfigGraphics.sh
Expand Up @@ -2,4 +2,4 @@
DIR=`dirname "$0"`

# purge all .jpg files over 1 day old
find "$DIR/www/configs" -name "*.jpg" \! \( -newerct '1 day ago' \) -delete
find "$DIR/www/configs" -name "*.jpg" \! \( -newerct '1 hour ago' \) -delete
6 changes: 3 additions & 3 deletions purgePrivateConfigs.py
Expand Up @@ -25,11 +25,11 @@ def hasReplay(self, bindPath):
replayPath = self.replayPath(bindPath)
return replayPath.exists()

def isOverOneDayOld(self, bindPath):
def isOverOneHourOld(self, bindPath):
stat = bindPath.stat()
fileTouchedTime = stat.st_ctime
now = time.time()
cutoff = now - 86400 # bad practice but good enough for this
cutoff = now - 3600
return fileTouchedTime < cutoff

def thoseWithoutReplay(self, bindingsPaths):
Expand All @@ -49,7 +49,7 @@ def purge(self):
sys.exit('%s not found' % self.configsDir)
allBindings = self.allBindings()
privateBindings = self.thoseWithoutReplay(allBindings)
oldPrivateBindings = [path for path in privateBindings if self.isOverOneDayOld(path)]
oldPrivateBindings = [path for path in privateBindings if self.isOverOneHourOld(path)]
deepListToPurge = [self.allFilesStartingWithStem(path) for path in oldPrivateBindings]
filesToPurge = [x for sublist in deepListToPurge for x in sublist]
for path in filesToPurge:
Expand Down

0 comments on commit ce2aa99

Please sign in to comment.