Permalink
Browse files

Second pass, deletes from filepicker

  • Loading branch information...
1 parent ed1574b commit 790a4872def43fc51629eae5436b043046635730 @oliversong committed Oct 21, 2013
Showing with 12 additions and 2 deletions.
  1. +1 −0 .meteor/packages
  2. +11 −2 server/crons.coffee
View
@@ -11,3 +11,4 @@ errors
spin
cron-tick
iron-router
+http
View
@@ -7,9 +7,18 @@ MyCron.addJob(1, ()->
ts = Math.round(new Date().getTime() / 1000)
expiredFiles = Files.find({dateCreated: {$lte: ts - 604800}}).fetch()
expiredBoxes = Boxes.find({dateCreated: {$lte: ts - 604800}}).fetch()
+ console.log("Found " + expiredBoxes.length + " expired boxes")
+ console.log("Found " + expiredFiles.length + " expired files")
for file in expiredFiles
- HTTP.del(file.url+"?key="+Meteor.filepickerKey)
- console.log "File " + file.name + " removed from filepicker."
+ url = file.url+"?key="+Meteor.filepickerKey
+ try
+ HTTP.del url, (error, result)->
+ if error
+ console.log "There was an error: " + error
+ else
+ console.log "File " + file.name + " removed from filepicker."
+ catch error
+ console.log "Something went wrong with the request: " + error
Boxes.remove({dateCreated: {$lte: ts - 604800}})
console.log("Removed " + expiredBoxes.length + " boxes")

0 comments on commit 790a487

Please sign in to comment.