More Greater Linting.
This commit is contained in:
@@ -36,6 +36,7 @@ var (
|
||||
|
||||
func New(cc *context.Context) {
|
||||
c = cc
|
||||
// nolint:exhaustivestruct
|
||||
d = &Database{}
|
||||
|
||||
c.Database.RegisterDialect(dialectinterface.Interface(Handler{}))
|
||||
|
@@ -38,6 +38,7 @@ func InitialUp(tx *sql.Tx) error {
|
||||
keep_for_unit_type int(1) NOT NULL DEFAULT 1 COMMENT 'Keep for unit type. 1 - minutes, 2 - hours, 3 - days, 4 - months.',
|
||||
PRIMARY KEY (id), UNIQUE KEY id (id)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Pastes';`)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import (
|
||||
func PasteLangUp(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` ADD `language` VARCHAR(191) NOT NULL DEFAULT 'text' COMMENT 'Paste language'")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -40,6 +41,7 @@ func PasteLangUp(tx *sql.Tx) error {
|
||||
func PasteLangDown(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` DROP COLUMN `language`")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import (
|
||||
func PrivatePastesUp(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` ADD `private` BOOL NOT NULL DEFAULT false COMMENT 'Private paste? If true - additional URL parameter (UNIX TIMESTAMP) of paste will be required to access.'")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -40,6 +41,7 @@ func PrivatePastesUp(tx *sql.Tx) error {
|
||||
func PrivatePastesDown(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` DROP COLUMN `private`")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,11 +31,13 @@ import (
|
||||
func PasswordedPastesUp(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` ADD `password` varchar(64) NOT NULL DEFAULT '' COMMENT 'Password for paste (scrypted and sha256ed).'")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
_, err1 := tx.Exec("ALTER TABLE `pastes` ADD `password_salt` varchar(64) NOT NULL DEFAULT '' COMMENT 'Password salt (sha256ed).'")
|
||||
if err1 != nil {
|
||||
// nolint:wrapcheck
|
||||
return err1
|
||||
}
|
||||
|
||||
@@ -45,11 +47,13 @@ func PasswordedPastesUp(tx *sql.Tx) error {
|
||||
func PasswordedPastesDown(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE `pastes` DROP COLUMN `password`")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
_, err1 := tx.Exec("ALTER TABLE `pastes` DROP COLUMN `password_salt`")
|
||||
if err1 != nil {
|
||||
// nolint:wrapcheck
|
||||
return err1
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
// MySQL driver.
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"go.dev.pztrn.name/fastpastebin/internal/database/dialects/mysql/migrations"
|
||||
@@ -58,6 +59,7 @@ func (db *Database) DeletePaste(pasteID int) error {
|
||||
|
||||
_, err := db.db.Exec(db.db.Rebind("DELETE FROM pastes WHERE id=?"), pasteID)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -78,10 +80,12 @@ func (db *Database) GetDatabaseConnection() *sql.DB {
|
||||
func (db *Database) GetPaste(pasteID int) (*structs.Paste, error) {
|
||||
db.check()
|
||||
|
||||
// nolint:exhaustivestruct
|
||||
p := &structs.Paste{}
|
||||
|
||||
err := db.db.Get(p, db.db.Rebind("SELECT * FROM `pastes` WHERE id=?"), pasteID)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -104,6 +108,7 @@ func (db *Database) GetPagedPastes(page int) ([]structs.Paste, error) {
|
||||
|
||||
err := db.db.Select(&pastesRaw, db.db.Rebind("SELECT * FROM `pastes` WHERE private != true ORDER BY id DESC LIMIT ? OFFSET ?"), c.Config.Pastes.Pagination, startPagination)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -186,11 +191,13 @@ func (db *Database) SavePaste(p *structs.Paste) (int64, error) {
|
||||
|
||||
result, err := db.db.NamedExec("INSERT INTO `pastes` (title, data, created_at, keep_for, keep_for_unit_type, language, private, password, password_salt) VALUES (:title, :data, :created_at, :keep_for, :keep_for_unit_type, :language, :private, :password, :password_salt)", p)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
return 0, err
|
||||
}
|
||||
|
||||
ID, err1 := result.LastInsertId()
|
||||
if err1 != nil {
|
||||
// nolint:wrapcheck
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user