mirror of
https://github.com/Dadido3/Scanyonero.git
synced 2025-06-06 01:10:00 +00:00
- 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.
42 lines
788 B
Go
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(),
|
|
},
|
|
)
|
|
}
|