From f85fe990ff57b7061c3f513af72862c4448a91b9 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Wed, 6 Nov 2024 18:31:22 +0100 Subject: [PATCH] Ignore macOS files, issue #37 --- cbconvert_convert.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cbconvert_convert.go b/cbconvert_convert.go index 3ffa395..f27a74e 100644 --- a/cbconvert_convert.go +++ b/cbconvert_convert.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "sync/atomic" "github.com/gen2brain/avif" @@ -166,9 +167,15 @@ func (c *Converter) convertArchive(ctx context.Context, fileName string) error { return c.imageConvert(ctx, img, 0, pathName) }) } - } else if !c.Opts.NoNonImage { - if err = copyFile(bytes.NewReader(data), filepath.Join(c.Workdir, filepath.Base(pathName))); err != nil { - return fmt.Errorf("convertArchive: %w", err) + } else { + if filepath.Ext(pathName) == ".DS_Store" || strings.Contains(pathName, "__MACOSX") { + continue + } + + if !c.Opts.NoNonImage { + if err = copyFile(bytes.NewReader(data), filepath.Join(c.Workdir, filepath.Base(pathName))); err != nil { + return fmt.Errorf("convertArchive: %w", err) + } } } }