-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at deleting expired files from mongo and filepicker
- Loading branch information
Oliver Song
committed
Oct 21, 2013
1 parent
57214fa
commit ed1574b
Showing
4 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
MyCron = new Cron() | |||
|
|||
MyCron.addJob(1, ()-> | |||
console.log "Garbage collecting old files and boxes..." | |||
# find all expired files and boxes and delete them, also remove files from filepicker | |||
# current timestamp | |||
ts = Math.round(new Date().getTime() / 1000) | |||
expiredFiles = Files.find({dateCreated: {$lte: ts - 604800}}).fetch() | |||
expiredBoxes = Boxes.find({dateCreated: {$lte: ts - 604800}}).fetch() | |||
for file in expiredFiles | |||
HTTP.del(file.url+"?key="+Meteor.filepickerKey) | |||
console.log "File " + file.name + " removed from filepicker." | |||
|
|||
Boxes.remove({dateCreated: {$lte: ts - 604800}}) | |||
console.log("Removed " + expiredBoxes.length + " boxes") | |||
Files.remove({dateCreated: {$lte: ts - 604800}}) | |||
console.log("Removed " + expiredFiles.length + " files") | |||
) |