Skip to content

Commit bb044d6

Browse files
author
Dominik Przybyl
committed
refactor
1 parent 755f642 commit bb044d6

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cmd/aem/content.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/spf13/cobra"
66
"github.com/wttech/aemc/pkg"
77
"github.com/wttech/aemc/pkg/common/pathx"
8+
"github.com/wttech/aemc/pkg/common/timex"
89
"github.com/wttech/aemc/pkg/content"
910
"os"
1011
"path/filepath"
@@ -76,6 +77,9 @@ func (c *CLI) contentDownloadCmd() *cobra.Command {
7677
return
7778
}
7879
pid, _ := cmd.Flags().GetString("pid")
80+
if pid == "" {
81+
pid = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
82+
}
7983
targetFile, _ := cmd.Flags().GetString("target-file")
8084
filterRoots := determineFilterRoots(cmd)
8185
filterFile, _ := cmd.Flags().GetString("filter-file")
@@ -133,6 +137,7 @@ func (c *CLI) contentPullCmd() *cobra.Command {
133137
replace, _ := cmd.Flags().GetBool("replace")
134138
if dir != "" {
135139
if err = instance.ContentManager().PullDir(dir, clean, vault, replace, pkg.PackageCreateOpts{
140+
PID: fmt.Sprintf("aemc:content-pull:%s-SNAPSHOT", timex.FileTimestampForNow()),
136141
FilterRoots: filterRoots,
137142
FilterFile: filterFile,
138143
}); err != nil {
@@ -142,6 +147,7 @@ func (c *CLI) contentPullCmd() *cobra.Command {
142147
c.SetOutput("dir", dir)
143148
} else if file != "" {
144149
if err = instance.ContentManager().PullFile(file, clean, vault, pkg.PackageCreateOpts{
150+
PID: fmt.Sprintf("aemc:content-pull:%s-SNAPSHOT", timex.FileTimestampForNow()),
145151
FilterRoots: filterRoots,
146152
ExcludePatterns: excludePatterns,
147153
}); err != nil {
@@ -196,6 +202,7 @@ func (c *CLI) contentPushCmd() *cobra.Command {
196202
clean, _ := cmd.Flags().GetBool("clean")
197203
vault, _ := cmd.Flags().GetBool("vault")
198204
if err = instance.ContentManager().Push(path, clean, vault, pkg.PackageCreateOpts{
205+
PID: fmt.Sprintf("aemc:content-push:%s-SNAPSHOT", timex.FileTimestampForNow()),
199206
FilterRoots: filterRoots,
200207
ExcludePatterns: excludePatterns,
201208
ContentPath: path,
@@ -241,6 +248,7 @@ func (c *CLI) contentCopyCmd() *cobra.Command {
241248
clean, _ := cmd.Flags().GetBool("clean")
242249
vault, _ := cmd.Flags().GetBool("vault")
243250
if err = instance.ContentManager().Copy(targetInstance, clean, vault, pkg.PackageCreateOpts{
251+
PID: fmt.Sprintf("aemc:content-copy:%s-SNAPSHOT", timex.FileTimestampForNow()),
244252
FilterRoots: filterRoots,
245253
FilterFile: filterFile,
246254
}); err != nil {

pkg/content_manager.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"github.com/wttech/aemc/pkg/common/filex"
66
"github.com/wttech/aemc/pkg/common/pathx"
7-
"github.com/wttech/aemc/pkg/common/timex"
87
"github.com/wttech/aemc/pkg/content"
98
"github.com/wttech/aemc/pkg/pkg"
109
"net/url"
@@ -45,9 +44,6 @@ func (cm *ContentManager) tmpDir() string {
4544
}
4645

4746
func (cm *ContentManager) pullContent(workDir string, vault bool, opts PackageCreateOpts) error {
48-
if opts.PID == "" {
49-
opts.PID = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
50-
}
5147
if vault {
5248
if err := copyPackageAllFiles(workDir, opts); err != nil {
5349
return err
@@ -82,9 +78,6 @@ func (cm *ContentManager) pullContent(workDir string, vault bool, opts PackageCr
8278
}
8379

8480
func (cm *ContentManager) downloadByPkgMgr(localFile string, opts PackageCreateOpts) error {
85-
if opts.PID == "" {
86-
opts.PID = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
87-
}
8881
remotePath, err := cm.pkgMgr().Create(opts)
8982
defer func() { _ = cm.pkgMgr().Delete(remotePath) }()
9083
if err != nil {
@@ -199,9 +192,6 @@ func (cm *ContentManager) Push(path string, clean bool, vault bool, opts Package
199192
}
200193
workDir := pathx.RandomDir(cm.tmpDir(), "content_push")
201194
defer func() { _ = pathx.DeleteIfExists(workDir) }()
202-
if opts.PID == "" {
203-
opts.PID = fmt.Sprintf("aemc:content-push:%s-SNAPSHOT", timex.FileTimestampForNow())
204-
}
205195
if clean || vault && pathx.IsFile(path) {
206196
if err := copyPackageAllFiles(workDir, opts); err != nil {
207197
return err

0 commit comments

Comments
 (0)