M4-M5: index strips and Lucio branding
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6d39dc1713
commit
45105d292f
47 files changed
+2016
-210
No files matched your search
@@ -76,6 +76,7 @@ type Processor struct {
|
||||
key []byte
|
||||
fingerprint string
|
||||
TilesDir string
|
||||
OGDir string
|
||||
StateDir string
|
||||
recordsDir string
|
||||
workDir string
|
||||
@@ -84,9 +85,10 @@ type Processor struct {
|
||||
|
||||
func New(ctx context.Context, cfg *config.Config) (*Processor, error) {
|
||||
tiles := filepath.Join(cfg.Paths.Output, "t")
|
||||
og := filepath.Join(cfg.Paths.Output, "og")
|
||||
records := filepath.Join(cfg.State, "pyramids")
|
||||
work := filepath.Join(cfg.Paths.Cache, "work")
|
||||
for _, dir := range []string{cfg.Paths.Output, tiles, cfg.State, records, cfg.Paths.Cache, work} {
|
||||
for _, dir := range []string{cfg.Paths.Output, tiles, og, cfg.State, records, cfg.Paths.Cache, work} {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -128,6 +130,7 @@ func New(ctx context.Context, cfg *config.Config) (*Processor, error) {
|
||||
key: key,
|
||||
fingerprint: fingerprint,
|
||||
TilesDir: tiles,
|
||||
OGDir: og,
|
||||
StateDir: cfg.State,
|
||||
recordsDir: records,
|
||||
workDir: work,
|
||||
@@ -185,6 +188,9 @@ type Job struct {
|
||||
}
|
||||
|
||||
func (j *Job) pixels() int {
|
||||
if j.Kind == "og" {
|
||||
return 0
|
||||
}
|
||||
if j.Crop != nil {
|
||||
return j.Crop[2] * j.Crop[3]
|
||||
}
|
||||
@@ -266,6 +272,38 @@ func (p *Processor) ForgetUnreferenced(keep map[string]bool) (int, error) {
|
||||
return removed, firstErr
|
||||
}
|
||||
|
||||
func (p *Processor) OGHash(src *Source, region [4]int) string {
|
||||
return p.hashWith(src.digest, fmt.Sprintf("og:%d,%d,%d,%d:%dx%d:q%d", region[0], region[1], region[2], region[3], OGWidth, OGHeight, OGQuality))
|
||||
}
|
||||
|
||||
func (p *Processor) HasOG(hash string) bool {
|
||||
info, err := os.Stat(filepath.Join(p.OGDir, hash+".jpg"))
|
||||
return err == nil && info.Mode().IsRegular() && info.Size() > 0
|
||||
}
|
||||
|
||||
func (p *Processor) ForgetOG(keep map[string]bool) (int, error) {
|
||||
entries, err := os.ReadDir(p.OGDir)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
removed := 0
|
||||
var firstErr error
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
if keep[strings.TrimSuffix(name, ".jpg")] {
|
||||
continue
|
||||
}
|
||||
if err := os.Remove(filepath.Join(p.OGDir, name)); err != nil {
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
continue
|
||||
}
|
||||
removed++
|
||||
}
|
||||
return removed, firstErr
|
||||
}
|
||||
|
||||
func (p *Processor) CleanWork() {
|
||||
entries, err := os.ReadDir(p.workDir)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user