A pretty basic pastes cleanup procedure.

Fixes #16.
This commit is contained in:
2021-01-09 06:09:26 +05:00
parent 3ebff29113
commit 164a37d41f
10 changed files with 124 additions and 8 deletions

View File

@@ -34,6 +34,10 @@ import (
type Handler struct{}
func (dbh Handler) DeletePaste(pasteID int) error {
return d.DeletePaste(pasteID)
}
func (dbh Handler) GetDatabaseConnection() *sql.DB {
return d.GetDatabaseConnection()
}

View File

@@ -56,6 +56,18 @@ func (db *Database) check() {
}
}
// DeletePaste deletes paste from database.
func (db *Database) DeletePaste(pasteID int) error {
db.check()
_, err := db.db.Exec(db.db.Rebind("DELETE FROM pastes WHERE id=?"), pasteID)
if err != nil {
return err
}
return nil
}
func (db *Database) GetDatabaseConnection() *sql.DB {
db.check()
@@ -89,7 +101,7 @@ func (db *Database) GetPagedPastes(page int) ([]structs.Paste, error) {
)
// Pagination.
var startPagination = 0
startPagination := 0
if page > 1 {
startPagination = (page - 1) * c.Config.Pastes.Pagination
}