Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push command #256

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e7e6d49
Revert "revert push command"
dominik-przybyl-wttech Apr 9, 2024
f9e017d
optimize regex
dominik-przybyl-wttech Apr 9, 2024
bc0d52f
refactor
dominik-przybyl-wttech May 6, 2024
99124e4
Merge branch 'main' into push-command
dominik-przybyl-wttech May 7, 2024
cc821ff
refactor
dominik-przybyl-wttech May 8, 2024
2dfe735
refactor
dominik-przybyl-wttech May 8, 2024
521caac
refactor
dominik-przybyl-wttech May 9, 2024
4adbc46
refactor
dominik-przybyl-wttech May 14, 2024
b38c131
refactor
dominik-przybyl-wttech May 14, 2024
424bcd2
minor
dominik-przybyl-wttech May 14, 2024
1637553
refactor
dominik-przybyl-wttech May 14, 2024
e2588b1
refactor
dominik-przybyl-wttech May 15, 2024
43b5612
refactor
dominik-przybyl-wttech May 17, 2024
7125182
minor
dominik-przybyl-wttech May 17, 2024
222a19e
added tests
dominik-przybyl-wttech May 18, 2024
c9d72a2
minor
dominik-przybyl-wttech May 19, 2024
c09427c
minor
dominik-przybyl-wttech May 19, 2024
1fc058f
refactor
dominik-przybyl-wttech May 19, 2024
605fbaf
refactor after CR
dominik-przybyl-wttech May 21, 2024
c7765d7
typo
dominik-przybyl-wttech May 21, 2024
99d89c1
fixed the large file issue (greater than 64KB)
dominik-przybyl-wttech May 22, 2024
6fbcf2f
Merge branch 'main' into push-command
dominik-przybyl-wttech Jun 9, 2024
03cc839
minor
dominik-przybyl-wttech Jun 10, 2024
eff71ee
Merge branch 'main' into push-command
dominik-przybyl-wttech Aug 5, 2024
8a2ca96
updated go dependencies
dominik-przybyl-wttech Aug 5, 2024
087e4ce
Merge branch 'small_fixes' into push-command
dominik-przybyl-wttech Aug 5, 2024
b94d5c8
Merge branch 'main' into push-command
dominik-przybyl-wttech Aug 6, 2024
589f19b
added test
dominik-przybyl-wttech Aug 20, 2024
63d8f57
minor
dominik-przybyl-wttech Aug 21, 2024
5fddff0
fix .content.xml file push
dominik-przybyl-wttech Aug 21, 2024
b67d822
fix .content.xml file push
dominik-przybyl-wttech Aug 22, 2024
5cfb16f
minor
dominik-przybyl-wttech Aug 22, 2024
c1c0406
refactor
dominik-przybyl-wttech Aug 22, 2024
5cbc41f
refactor
dominik-przybyl-wttech Aug 22, 2024
a8f78f8
refactor
dominik-przybyl-wttech Aug 22, 2024
9b85802
remove JCRContentFile const
dominik-przybyl-wttech Aug 22, 2024
e4707f0
simplify pull file
dominik-przybyl-wttech Aug 22, 2024
e1399aa
simplify pull file
dominik-przybyl-wttech Aug 22, 2024
88a3fa4
Merge branch 'main' into push-command
dominik-przybyl-wttech Aug 23, 2024
6a62db3
simplify pull file
dominik-przybyl-wttech Aug 23, 2024
055ae03
simplify pull file
dominik-przybyl-wttech Aug 23, 2024
90cf57d
Merge branch 'simplify-pull-file' into push-command
dominik-przybyl-wttech Aug 24, 2024
23879c1
minor
dominik-przybyl-wttech Aug 24, 2024
f5a3ee7
minor
dominik-przybyl-wttech Aug 24, 2024
53197ac
minor
dominik-przybyl-wttech Aug 24, 2024
0633cb8
minor
dominik-przybyl-wttech Aug 24, 2024
0e4accf
refactor
dominik-przybyl-wttech Aug 24, 2024
845f881
refactor
dominik-przybyl-wttech Aug 24, 2024
6fbf1c9
fixed .content.xml issue
dominik-przybyl-wttech Aug 28, 2024
5abac45
minor
Aug 28, 2024
a543970
minor
Aug 28, 2024
418f4de
refactor
Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 75 additions & 6 deletions cmd/aem/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func (c *CLI) contentCmd() *cobra.Command {
}
cmd.AddCommand(c.contentCleanCmd())
cmd.AddCommand(c.contentPullCmd())
cmd.AddCommand(c.contentPushCmd())
cmd.AddCommand(c.contentDownloadCmd())
cmd.AddCommand(c.contentCopyCmd())
return cmd
Expand Down Expand Up @@ -74,7 +75,7 @@ func (c *CLI) contentDownloadCmd() *cobra.Command {
}
pid, _ := cmd.Flags().GetString("pid")
targetFile, _ := cmd.Flags().GetString("target-file")
filterRoots, _ := cmd.Flags().GetStringSlice("filter-roots")
filterRoots := determineFilterRoots(cmd)
filterFile, _ := cmd.Flags().GetString("filter-file")
if err = instance.ContentManager().Download(targetFile, pkg.PackageCreateOpts{
PID: pid,
Expand Down Expand Up @@ -120,21 +121,20 @@ func (c *CLI) contentPullCmd() *cobra.Command {
c.Error(err)
return
}
filterRoots := determineFilterRoots(cmd)
filterFile, _ := cmd.Flags().GetString("filter-file")
if dir != "" {
filterRoots, _ := cmd.Flags().GetStringSlice("filter-roots")
filterFile, _ := cmd.Flags().GetString("filter-file")
if err = instance.ContentManager().PullDir(dir, clean, replace, pkg.PackageCreateOpts{
FilterRoots: filterRoots,
FilterFile: filterFile,
ContentDir: dir,
}); err != nil {
c.Error(err)
return
}
c.SetOutput("dir", dir)
} else if file != "" {
if err = instance.ContentManager().PullFile(file, clean, pkg.PackageCreateOpts{
ContentFile: file,
FilterRoots: filterRoots,
}); err != nil {
c.Error(err)
return
Expand All @@ -156,6 +156,55 @@ func (c *CLI) contentPullCmd() *cobra.Command {
return cmd
}

func (c *CLI) contentPushCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "push",
Aliases: []string{"ps"},
Short: "Push content from JCR root directory or local file to running instance",
Run: func(cmd *cobra.Command, args []string) {
instance, err := c.aem.InstanceManager().One()
if err != nil {
c.Error(err)
return
}
dir, err := determineContentDir(cmd)
if err != nil {
c.Error(err)
return
}
file, err := determineContentFile(cmd)
if err != nil {
c.Error(err)
return
}
path := dir
if path == "" {
path = file
}
clean, _ := cmd.Flags().GetBool("clean")
filterRoots := determineFilterRoots(cmd)
if err = instance.ContentManager().Push(clean, path, pkg.PackageCreateOpts{
FilterRoots: filterRoots,
}); err != nil {
c.Error(err)
return
}
if dir != "" {
c.SetOutput("dir", dir)
} else if file != "" {
c.SetOutput("file", file)
}
c.Changed("content pushed")
},
}
cmd.Flags().StringP("dir", "d", "", "JCR root path")
cmd.Flags().StringP("file", "f", "", "Local file path")
cmd.Flags().StringP("path", "p", "", "JCR root path or local file path")
cmd.MarkFlagsOneRequired("dir", "file", "path")
cmd.Flags().Bool("clean", false, "Normalize content while uploading")
return cmd
}

func (c *CLI) contentCopyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "copy",
Expand All @@ -172,7 +221,7 @@ func (c *CLI) contentCopyCmd() *cobra.Command {
c.Error(err)
return
}
filterRoots, _ := cmd.Flags().GetStringSlice("filter-roots")
filterRoots := determineFilterRoots(cmd)
filterFile, _ := cmd.Flags().GetString("filter-file")
clean, _ := cmd.Flags().GetBool("clean")
if err = instance.ContentManager().Copy(targetInstance, clean, pkg.PackageCreateOpts{
Expand Down Expand Up @@ -246,3 +295,23 @@ func determineContentFile(cmd *cobra.Command) (string, error) {
}
return file, nil
}

func determineFilterRoots(cmd *cobra.Command) []string {
filterRoots, _ := cmd.Flags().GetStringSlice("filter-roots")
if len(filterRoots) > 0 {
return filterRoots
}
filterFile, _ := cmd.Flags().GetString("filter-file")
if filterFile != "" {
return nil
}
dir, _ := determineContentDir(cmd)
if dir != "" {
return []string{pkg.DetermineFilterRoot(dir)}
}
file, _ := determineContentFile(cmd)
if file != "" {
return []string{pkg.DetermineFilterRoot(file)}
}
return nil
}
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/antchfx/xmlquery v1.3.18
github.com/cheggaaa/pb/v3 v3.1.4
github.com/codingsince1985/checksum v1.3.0
github.com/dominik-przybyl-wttech/archiver/v3 v3.5.4
github.com/dustin/go-humanize v1.0.1
github.com/essentialkaos/go-jar v1.0.6
github.com/fatih/color v1.16.0
Expand All @@ -21,6 +20,7 @@ require (
github.com/jmespath-community/go-jmespath v1.1.1
github.com/joho/godotenv v1.5.1
github.com/magiconair/properties v1.8.7
github.com/mholt/archiver/v3 v3.5.1
github.com/olekukonko/tablewriter v0.0.5
github.com/otiai10/copy v1.14.0
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
Expand All @@ -39,30 +39,30 @@ require (
require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/xpath v1.2.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.2 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pierrec/lz4/v4 v4.1.19 // indirect
github.com/pierrec/lz4/v4 v4.1.2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
Expand All @@ -71,7 +71,7 @@ require (
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
Expand Down
26 changes: 10 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VP
github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/antchfx/xmlquery v1.3.18 h1:FSQ3wMuphnPPGJOFhvc+cRQ2CT/rUj4cyQXkJcjOwz0=
Expand All @@ -27,8 +26,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dominik-przybyl-wttech/archiver/v3 v3.5.4 h1:GtTMZL6GyHHhRxjczvH4i/rfxlIBSyOx/CdmKK+WjkA=
github.com/dominik-przybyl-wttech/archiver/v3 v3.5.4/go.mod h1:1ovifw9KHloKamchb6IZrdeOIKBKRDpNfTCRPiTA6Ik=
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY=
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s=
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
Expand All @@ -48,9 +45,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw=
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -74,12 +70,11 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM=
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=
github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
Expand All @@ -92,26 +87,26 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM=
github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.19 h1:tYLzDnjDXh9qIxSTKHwXwOYmm9d887Y7Y1ZkyXYHAN4=
github.com/pierrec/lz4/v4 v4.1.19/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -156,9 +151,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I=
github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/filex/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package filex

import (
"fmt"
"github.com/dominik-przybyl-wttech/archiver/v3" // TODO improve archiver itself?
"github.com/mholt/archiver/v3"
"github.com/samber/lo"
"github.com/wttech/aemc/pkg/common/pathx"
"os"
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/pathx/pathx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ExistsStrict(path string) (bool, error) {
}

func IsFile(path string) bool {
return !IsDir(path)
return Exists(path) && !IsDir(path)
}

func IsDir(path string) bool {
Expand Down
27 changes: 9 additions & 18 deletions pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,15 @@ func readLines(path string) ([]string, error) {

var lines []string
scanner := bufio.NewScanner(file)
fileStat, err := file.Stat()
if err != nil {
return nil, err
}
if fileStat.Size() > bufio.MaxScanTokenSize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wth ?:D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffer size of the scanner is 64 KB, if file is larger than 64K, you can set larger buffer with scanner.Buffer

size := fileStat.Size()
buffer := make([]byte, size)
scanner.Buffer(buffer, int(size))
}
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
Expand Down Expand Up @@ -512,21 +521,3 @@ func determineStringSlice(values any, key string) []string {
}
return result
}

func IsContentFile(path string) bool {
if !strings.HasSuffix(path, JCRContentFile) {
return false
}

inputLines, err := readLines(path)
if err != nil {
return false
}

for _, inputLine := range inputLines {
if strings.Contains(inputLine, JCRContentPrefix) {
return true
}
}
return false
}
Loading
Loading