Maintain deletes check files that are older than sql.CheckExpiry.
()
| 175 | |
| 176 | // Maintain deletes check files that are older than sql.CheckExpiry. |
| 177 | func (sql Storage) Maintain() error { |
| 178 | if sql.CheckExpiry == 0 { |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | db, err := sql.dbConnect() |
| 183 | if err != nil { |
| 184 | return err |
| 185 | } |
| 186 | defer db.Close() |
| 187 | |
| 188 | const st = `DELETE FROM "checks" WHERE timestamp < ?` |
| 189 | ts := time.Now().Add(-1 * sql.CheckExpiry).UnixNano() |
| 190 | _, err = db.Exec(st, ts) |
| 191 | return err |
| 192 | } |
| 193 | |
| 194 | // initialize creates the "checks" table in the database. |
| 195 | func (sql Storage) initialize() error { |