M6: serve and export modes, packaging

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
lucioandClaude Opus 5.5 committed 2026-11-04 04:58:48 -08:00
1 parent 45105d292f
commit 00ee2a6d12
29 files changed
+1294 -75

No files matched your search

+28 -1
View File
@@ -314,6 +314,30 @@ func (p *Processor) seed(ctx context.Context, src, work string) (string, error)
return base64.StdEncoding.EncodeToString(data), nil
}
func levelDir(files string) (string, error) {
entries, err := os.ReadDir(files)
if err != nil {
return "", err
}
found := ""
for _, entry := range entries {
if !entry.IsDir() {
continue
}
if _, err := strconv.Atoi(entry.Name()); err != nil {
continue
}
if found != "" {
return "", fmt.Errorf("dzsave wrote more than one level in %s", files)
}
found = filepath.Join(files, entry.Name())
}
if found == "" {
return "", fmt.Errorf("dzsave wrote no level in %s", files)
}
return found, nil
}
type tileFile struct {
name string
x, y int
@@ -331,7 +355,10 @@ func (p *Processor) cutLevel(ctx context.Context, hash, src, stage string, level
"--suffix", ext+p.vips.SaveOptions(quality)); err != nil {
return Level{}, err
}
dir := filepath.Join(base+"_files", "0")
dir, err := levelDir(base + "_files")
if err != nil {
return Level{}, err
}
entries, err := os.ReadDir(dir)
if err != nil {
return Level{}, err
+12 -1
View File
@@ -20,8 +20,11 @@ type Vips struct {
Minor int
Strip string
env []string
nice string
}
const niceIncrement = "5"
var versionPattern = regexp.MustCompile(`vips-(\d+)\.(\d+)(\.\d+)?`)
func DetectVips(ctx context.Context, env []string) (*Vips, error) {
@@ -42,6 +45,9 @@ func DetectVips(ctx context.Context, env []string) (*Vips, error) {
major, _ := strconv.Atoi(m[1])
minor, _ := strconv.Atoi(m[2])
v := &Vips{Version: strings.TrimPrefix(m[0], "vips-"), Major: major, Minor: minor, env: env}
if nice, err := exec.LookPath("nice"); err == nil {
v.nice = nice
}
if major > 8 || (major == 8 && minor >= 15) {
v.Strip = "keep=none"
} else {
@@ -70,7 +76,12 @@ func (l *limitedBuffer) Write(p []byte) (int, error) {
}
func (v *Vips) Run(ctx context.Context, args ...string) error {
cmd := exec.CommandContext(ctx, "vips", args...)
var cmd *exec.Cmd
if v.nice != "" {
cmd = exec.CommandContext(ctx, v.nice, append([]string{"-n", niceIncrement, "vips"}, args...)...)
} else {
cmd = exec.CommandContext(ctx, "vips", args...)
}
cmd.Env = v.env
stderr := &limitedBuffer{limit: 4096}
cmd.Stderr = stderr