diff --git a/plugins/diff/erofs/differ.go b/plugins/diff/erofs/differ.go index c89ad2ddf..a3a1b6df3 100644 --- a/plugins/diff/erofs/differ.go +++ b/plugins/diff/erofs/differ.go @@ -22,6 +22,7 @@ import ( "io" "os" "path" + "runtime" "strings" "time" @@ -82,6 +83,9 @@ func NewErofsDiffer(store content.Store, opts ...DifferOpt) differ { opt(d) } + // Add default block size on darwin if not already specified + d.mkfsExtraOpts = addDefaultMkfsOpts(d.mkfsExtraOpts) + return d } @@ -211,3 +215,21 @@ func (rc *readCounter) Read(p []byte) (n int, err error) { rc.c += int64(n) return } + +// addDefaultMkfsOpts adds default options for mkfs.erofs +func addDefaultMkfsOpts(mkfsExtraOpts []string) []string { + if runtime.GOOS != "darwin" { + return mkfsExtraOpts + } + + // Check if -b argument is already present + for _, opt := range mkfsExtraOpts { + if strings.HasPrefix(opt, "-b") { + return mkfsExtraOpts + } + } + + // Add -b4096 as the first option to prevent unusable block + // size from being used on macOS. + return append([]string{"-b4096"}, mkfsExtraOpts...) +}