feat: [WIP] implement scp by bgo
This commit is contained in:
@@ -69,6 +69,12 @@ func (s *CaptureAndSSHService) ExecuteWithBytes(ctx context.Context, pngBytes []
|
||||
return fmt.Errorf("empty screenshot")
|
||||
}
|
||||
relPath := buildRemoteRelPath(s.Cfg.PathPrefix)
|
||||
// bgo cannot create remote directories, so it uploads flat into the
|
||||
// remote $HOME with a timestamped filename rather than a date-grouped
|
||||
// subdirectory tree (see BgoUploader for the rationale).
|
||||
if s.Cfg.IsBgo() {
|
||||
relPath = buildRemoteFlatName()
|
||||
}
|
||||
sshSvcLog().Info("save-remote pipeline start",
|
||||
"host", s.Cfg.Host, "user", s.Cfg.User, "port", s.Cfg.Port,
|
||||
"size", len(pngBytes), "remote_path", relPath,
|
||||
@@ -128,6 +134,17 @@ func buildRemoteRelPath(prefix string) string {
|
||||
)
|
||||
}
|
||||
|
||||
// buildRemoteFlatName produces a flat, timestamped filename (no directory
|
||||
// components) for destinations that cannot create remote directories, such
|
||||
// as the bgo client. The file lands directly in the remote $HOME.
|
||||
func buildRemoteFlatName() string {
|
||||
now := time.Now()
|
||||
return fmt.Sprintf("%s-%s.png",
|
||||
now.Format("20060102-150405"),
|
||||
randomSuffix(6),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *CaptureAndSSHService) notifyFailure(reason string) {
|
||||
if s.Notifier != nil {
|
||||
s.Notifier.NotifyFailure(reason)
|
||||
|
||||
Reference in New Issue
Block a user