Skip to content

Commit

Permalink
clear out old sprunges by size, not just the oldest one
Browse files Browse the repository at this point in the history
  • Loading branch information
rupa committed Feb 28, 2013
1 parent e165d63 commit 87f1566
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sprunge.py
Expand Up @@ -123,9 +123,13 @@ def post(self, got):
s.content = self.request.get(self.r)
s.name = nid

# delete the oldest sprunge
old = Sprunge.gql('ORDER BY date ASC LIMIT 1').get()
if old:
# clear out same amount of space we're using up
cleared = len(s.content)
while cleared > 0:
old = Sprunge.gql('ORDER BY date ASC LIMIT 1').get()
if not old:
break
cleared -= len(old.content)
old.delete()

s.put()
Expand Down

2 comments on commit 87f1566

@4d47
Copy link

@4d47 4d47 commented on 87f1566 Jul 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this, why doesnt only keep the last sprunge in the database ? I mean if the db is empty a new sprunge will always delete the previous one. Would be cool to be able to configure until when a sprunge is deleted.

@rupa
Copy link
Owner Author

@rupa rupa commented on 87f1566 Jul 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a crappy hack cause i was running out of space on app engine

Please sign in to comment.