Scanyonero/queue-entry.go
David Vogel 853a1bb58d Rework into FTP scanning server
- Rename to Scanyonero
- Add FTP server that ingests TIFF, PNG, JPEG or PDF files
- Add web interface to check and modify ingested files
- Rework how ocrmypdf is invoked

Basics are working, but the program is not in a usable state.
2025-05-14 12:08:38 +02:00

42 lines
788 B
Go

package main
import (
"encoding/json"
"fmt"
"sync/atomic"
)
var queueEntryIDCounter atomic.Uint32
// NewQueueEntryID returns a unique document id.
func NewQueueEntryID() QueueEntryID {
return QueueEntryID(queueEntryIDCounter.Add(1))
}
type QueueEntryID int
// QueueEntry can contain a single or multiple scanned pages.
type QueueEntry struct {
ID QueueEntryID `json:"id"`
Name string `json:"name"`
QueueEntryData
}
func (q QueueEntry) MarshalJSON() ([]byte, error) {
if q.QueueEntryData == nil {
return nil, fmt.Errorf("queue entry doesn't contain any data")
}
type embedded QueueEntry // Prevent recursion.
return json.Marshal(
struct {
embedded
Type string `json:"type"`
}{
embedded: embedded(q),
Type: q.QueueEntryDataType(),
},
)
}