feat(files): Add deployment content push - #6
Conversation
Code Review SummaryThis PR adds the capability to push a local directory to a deployment in a single request. It includes updates to the CLI command structure, the underlying API client, and comprehensive tests. 🚀 Key Improvements
💡 Minor Suggestions
|
| if path == source { | ||
| return nil | ||
| } | ||
| info, err := entry.Info() |
There was a problem hiding this comment.
Optimization: You can check if the entry is a symbolic link using entry.Type() before calling entry.Info(). Since entry.Type() is typically available directly from the directory traversal (e.g., via getdents on Linux), this can avoid an unnecessary stat syscall for every file in the directory tree, significantly improving performance for large source directories.
| info, err := entry.Info() | |
| + if entry.Type()&os.ModeSymlink != 0 { | |
| + return fmt.Errorf("symbolic links are not supported: %s", path) | |
| + } | |
| + info, err := entry.Info() | |
| + if err != nil { | |
| + return err | |
| + } |
Large directory pushes now reject symbolic links without an extra file metadata lookup.
| } | ||
| req.Header.Set("Accept", "application/json") | ||
| req.Header.Set("Content-Type", multipartWriter.FormDataContentType()) | ||
| if c.token != "" { |
There was a problem hiding this comment.
The Authorization header setting is duplicated here and in the main request logic (as seen in internal/flatrun/client.go). To ensure consistency and simplify future changes (e.g., changing auth schemes), consider extracting this into a private helper method on the Client struct.
| if c.token != "" { | |
| c.setAuthHeader(req) | |
Push a local directory to a deployment in one request, with optional destination cleanup.