Add support for tab-completion when selecting by rule
[alpine.git] / web / cgi / alpine / whackatch.tcl
blobcca94724525897f94a8ee74f9d25d6890b799eba
1 #!./tclsh
2 # $Id: whackatch.tcl 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $
3 # ========================================================================
4 # Copyright 2006 University of Washington
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # ========================================================================
14 # whackatch.tcl
16 # Purpose: CGI script to cleanup requested attachment
18 # Input:
19 # ext - attachment file extension
21 # Output:
24 # inherit global config
25 source ./alpine.tcl
27 # seconds to pause before rechecking for abandanded attachment files
28 set abandoned 300
30 # no dots allowed
31 if {[gets stdin ext] >= 0 && [regexp {^[A-Za-z0-9\-]+$} $ext ext] == 1} {
33 set towhack [file join $_wp(fileroot) $_wp(detachpath) detach.${ext}]
35 while {1} {
36 set timein [clock seconds]
38 after [expr {$abandoned * 1000}]
40 if {[catch {file atime $towhack} atime] || ($timein - $atime) > $abandoned} {
41 break
45 catch {exec /bin/rm -f $towhack}