Skip to content

Commit 37fbd40

Browse files
committed
Buffer slightly more for zstd
I think this is not a long-term fix but it gets us enough to "fix" a layer someone pointed out to me, so /shrug
1 parent 62f0983 commit 37fbd40

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

internal/forks/http/fs.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import (
2929
"time"
3030

3131
"github.com/dustin/go-humanize"
32-
"github.com/jonjohnsonjr/dagdotdev/pkg/forks/github.com/google/go-containerregistry/pkg/logs"
3332
"github.com/jonjohnsonjr/dagdotdev/internal/forks/elf"
3433
"github.com/jonjohnsonjr/dagdotdev/internal/forks/safefilepath"
3534
"github.com/jonjohnsonjr/dagdotdev/internal/xxd"
35+
"github.com/jonjohnsonjr/dagdotdev/pkg/forks/github.com/google/go-containerregistry/pkg/logs"
3636
"golang.org/x/exp/slices"
3737
)
3838

@@ -481,6 +481,9 @@ func tarListAll(i int, dirs anyDirs, fi fs.FileInfo, u url.URL, uprefix, fprefix
481481
header, ok := fi.Sys().(*tar.Header)
482482
if !ok {
483483
name := fi.Name()
484+
if fi.IsDir() {
485+
name += "/"
486+
}
484487
ts := "????-??-?? ??:??"
485488
ug := "?/?"
486489
mode := "d?????????"
@@ -496,6 +499,9 @@ func tarListAll(i int, dirs anyDirs, fi fs.FileInfo, u url.URL, uprefix, fprefix
496499
s := fmt.Sprintf("%s %s <span title=%q>%*d</span> %s", mode, ug, humanize.IBytes(uint64(header.Size)), padding, header.Size, ts)
497500

498501
name := dirs.name(i)
502+
if dirs.isDir(i) {
503+
name += "/"
504+
}
499505
if header.Linkname != "" {
500506
if header.Linkname == "." {
501507
u.Path = path.Dir(u.Path)
@@ -535,6 +541,9 @@ func tarList(i int, dirs anyDirs, showlayer bool, fi fs.FileInfo, u url.URL, upr
535541
header, ok := fi.Sys().(*tar.Header)
536542
if !ok {
537543
name := fi.Name()
544+
if fi.IsDir() {
545+
name += "/"
546+
}
538547
ts := "????-??-?? ??:??"
539548
ug := "?/?"
540549
mode := "d?????????"
@@ -564,6 +573,9 @@ func tarList(i int, dirs anyDirs, showlayer bool, fi fs.FileInfo, u url.URL, upr
564573
s = prefix + " " + s
565574
}
566575
name := fi.Name()
576+
if fi.IsDir() {
577+
name += "/"
578+
}
567579
if header.Linkname != "" {
568580
if header.Linkname == "." {
569581
u.Path = path.Dir(u.Path)
@@ -615,6 +627,9 @@ func tarListSize(i int, dirs anyDirs, showlayer bool, fi fs.FileInfo, u url.URL,
615627
header, ok := fi.Sys().(*tar.Header)
616628
if !ok {
617629
name := fi.Name()
630+
if fi.IsDir() {
631+
name += "/"
632+
}
618633
ts := "????-??-?? ??:??"
619634
ug := "?/?"
620635
mode := "d?????????"
@@ -647,6 +662,9 @@ func tarListSize(i int, dirs anyDirs, showlayer bool, fi fs.FileInfo, u url.URL,
647662
s = fmt.Sprintf("<small>%*s</small> ", ownerLength, owner) + s
648663
}
649664
name := dirs.name(i)
665+
if dirs.isDir(i) {
666+
name += "/"
667+
}
650668
if header.Linkname != "" {
651669
if header.Linkname == "." {
652670
u.Path = path.Dir(u.Path)
@@ -692,6 +710,9 @@ func TarList(fi fs.FileInfo, u url.URL, uprefix string) string {
692710
header, ok := fi.Sys().(*tar.Header)
693711
if !ok {
694712
name := fi.Name()
713+
if fi.IsDir() {
714+
name += "/"
715+
}
695716
ts := "????-??-?? ??:??"
696717
ug := "?/?"
697718
mode := "d?????????"
@@ -706,6 +727,9 @@ func TarList(fi fs.FileInfo, u url.URL, uprefix string) string {
706727
padding := 18 - len(ug)
707728
s := fmt.Sprintf("%s %s <span title=%q>%*d</span> %s", mode, ug, humanize.IBytes(uint64(header.Size)), padding, header.Size, ts)
708729
name := fi.Name()
730+
if fi.IsDir() {
731+
name += "/"
732+
}
709733
if header.Linkname != "" {
710734
if header.Linkname == "." {
711735
u.Path = path.Dir(u.Path)

internal/soci/peek.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111

1212
kzstd "github.com/jonjohnsonjr/dagdotdev/pkg/forks/github.com/klauspost/compress/zstd"
1313

14-
"github.com/jonjohnsonjr/dagdotdev/pkg/forks/github.com/google/go-containerregistry/pkg/logs"
1514
"github.com/jonjohnsonjr/dagdotdev/internal/and"
1615
"github.com/jonjohnsonjr/dagdotdev/internal/gzip"
1716
"github.com/jonjohnsonjr/dagdotdev/internal/zstd"
17+
"github.com/jonjohnsonjr/dagdotdev/pkg/forks/github.com/google/go-containerregistry/pkg/logs"
1818
)
1919

2020
const (
@@ -35,11 +35,11 @@ type PeekReader interface {
3535
// zstd
3636
func Peek(rc io.ReadCloser) (string, io.ReadCloser, io.ReadCloser, error) {
3737
logs.Debug.Printf("Peek")
38-
buf := bufio.NewReaderSize(rc, 1<<16)
38+
buf := bufio.NewReaderSize(rc, 1<<18)
3939
pr := &and.ReadCloser{Reader: buf, CloseFunc: rc.Close}
4040

4141
// Should be enough to read first block?
42-
zb, err := buf.Peek(1 << 16)
42+
zb, err := buf.Peek(1 << 18)
4343
if err != nil {
4444
if err != io.EOF {
4545
return "", pr, nil, fmt.Errorf("buf.Peek: %w", err)

0 commit comments

Comments
 (0)