Skip to content

Commit 352f43a

Browse files
authored
Fix incorrect copy . . handling (#1332)
1 parent 4e99235 commit 352f43a

File tree

1 file changed

+10
-4
lines changed
  • packages/orchestrator/internal/template/build/commands

1 file changed

+10
-4
lines changed

packages/orchestrator/internal/template/build/commands/copy.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/bmatcuk/doublestar/v4"
1414
"go.uber.org/zap"
15+
"go.uber.org/zap/zapcore"
1516

1617
"github.com/e2b-dev/infra/packages/orchestrator/internal/proxy"
1718
"github.com/e2b-dev/infra/packages/orchestrator/internal/template/build/sandboxtools"
@@ -67,7 +68,8 @@ elif [ -f "$entry" ]; then
6768
elif [ -d "$entry" ]; then
6869
# It's a directory – move all its contents into the destination folder
6970
mkdir -p "$targetPath"
70-
mv "$entry"/* "$targetPath/"
71+
# Move all contents including hidden files
72+
find "$entry" -mindepth 1 -maxdepth 1 -exec mv {} "$targetPath/" \;
7173
else
7274
echo "Error: entry is neither file nor directory"
7375
exit 1
@@ -87,7 +89,7 @@ fi
8789
// because the /tmp is mounted as a tmpfs and deleted on restart.
8890
func (c *Copy) Execute(
8991
ctx context.Context,
90-
_ *zap.Logger,
92+
logger *zap.Logger,
9193
proxy *proxy.SandboxProxy,
9294
sandboxID string,
9395
_ string,
@@ -141,7 +143,8 @@ func (c *Copy) Execute(
141143
return metadata.Context{}, fmt.Errorf("failed to copy layer tar data to sandbox: %w", err)
142144
}
143145

144-
sbxUnpackPath := filepath.Join("/tmp", step.GetFilesHash())
146+
// Create nested unpack directory to allow multiple files in the root be correctly detected
147+
sbxUnpackPath := filepath.Join("/tmp", step.GetFilesHash(), "unpack")
145148

146149
// 3) Extract the tar file in the sandbox's /tmp directory
147150
err = sandboxtools.RunCommand(
@@ -169,9 +172,12 @@ func (c *Copy) Execute(
169172
return metadata.Context{}, fmt.Errorf("failed to execute copy script template: %w", err)
170173
}
171174

172-
err = sandboxtools.RunCommand(
175+
err = sandboxtools.RunCommandWithLogger(
173176
ctx,
174177
proxy,
178+
logger,
179+
zapcore.DebugLevel,
180+
"unpack",
175181
sandboxID,
176182
moveScript.String(),
177183
cmdMetadata,

0 commit comments

Comments
 (0)