Pastebin

Check-in [064b0cd9a2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Custom error message on invalid paste
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 064b0cd9a2081bae8395a946624839608ea02ada272175279c1bc88edf90832a
User & Date: jef 2019-11-06 21:03:57
Context
2019-11-11
08:56
Improve rendering on mobile phones check-in: 353077eadb user: jef tags: trunk
2019-11-06
21:03
Custom error message on invalid paste check-in: 064b0cd9a2 user: jef tags: trunk
20:27
Simplify DB queries check-in: bbe49e890d user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to db.go.

1
2
3
4

5
6
7
8
9
10
11
...
127
128
129
130
131
132
133



134
135
package main

import (
	"database/sql"

	"fmt"
	_ "github.com/mattn/go-sqlite3"
	"os"
	"path/filepath"
	"strings"
)

................................................................................
	_, err := p.db.Exec(`DELETE FROM pastes WHERE inserttime < datetime('now', ?, 'localtime');`, delay)
	return err
}

func (p *PasteBinDb) Get(pasteid string) (pdata *PasteData, err error) {
	pdata = &PasteData{}
	err = p.db.QueryRow(`SELECT data, mimetype FROM pastes WHERE pasteid = ?`, pasteid).Scan(&pdata.Data, &pdata.MimeType)



	return
}




>







 







>
>
>


1
2
3
4
5
6
7
8
9
10
11
12
...
128
129
130
131
132
133
134
135
136
137
138
139
package main

import (
	"database/sql"
	"errors"
	"fmt"
	_ "github.com/mattn/go-sqlite3"
	"os"
	"path/filepath"
	"strings"
)

................................................................................
	_, err := p.db.Exec(`DELETE FROM pastes WHERE inserttime < datetime('now', ?, 'localtime');`, delay)
	return err
}

func (p *PasteBinDb) Get(pasteid string) (pdata *PasteData, err error) {
	pdata = &PasteData{}
	err = p.db.QueryRow(`SELECT data, mimetype FROM pastes WHERE pasteid = ?`, pasteid).Scan(&pdata.Data, &pdata.MimeType)
	if err == sql.ErrNoRows {
		return nil, errors.New("Paste not found")
	}
	return
}