forked from electricdusk/rushlink
db: Add missing docs to public symbols
This commit is contained in:
parent
62e82d831e
commit
76cf92e22d
@ -14,9 +14,13 @@ import (
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
// PasteType describes the type of Paste (i.e. file, redirect, [...]).
|
||||
type PasteType int
|
||||
|
||||
// PasteState describes the state of a Paste (i.e. present, deleted, [...]).
|
||||
type PasteState int
|
||||
|
||||
// Paste describes the main Paste model in the database.
|
||||
type Paste struct {
|
||||
Type PasteType
|
||||
State PasteState
|
||||
@ -35,6 +39,8 @@ var ReservedPasteKeys = []string{"xd42", "example"}
|
||||
// allowed at the bottom of this block, for the same reason.
|
||||
const (
|
||||
PasteTypeUndef PasteType = iota
|
||||
// PasteTypePaste is as of yet unused. It is still unclear if this type
|
||||
// will ever get a proper meaning.
|
||||
PasteTypePaste
|
||||
PasteTypeRedirect
|
||||
PasteTypeFileUpload
|
||||
@ -94,6 +100,7 @@ func GetPaste(tx *bolt.Tx, key string) (*Paste, error) {
|
||||
return p, err
|
||||
}
|
||||
|
||||
// Save saves this Paste to the database.
|
||||
func (p *Paste) Save(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket([]byte(BucketPastes))
|
||||
if bucket == nil {
|
||||
@ -110,6 +117,7 @@ func (p *Paste) Save(tx *bolt.Tx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes this Paste from the database.
|
||||
func (p *Paste) Delete(tx *bolt.Tx, fs *FileStore) error {
|
||||
// Remove the (maybe) attached file
|
||||
if p.Type == PasteTypeFileUpload {
|
||||
@ -226,6 +234,7 @@ func generatePasteKeyInner(epoch int) (string, error) {
|
||||
return string(urlKey), nil
|
||||
}
|
||||
|
||||
// GenerateDeleteToken generates a new (random) delete token.
|
||||
func GenerateDeleteToken() (string, error) {
|
||||
var deleteToken [16]byte
|
||||
_, err := rand.Read(deleteToken[:])
|
||||
|
Loading…
Reference in New Issue
Block a user