feat: convert local file to memory file
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
97f89d210b
commit
739069a18f
|
@ -1,6 +1,7 @@
|
||||||
package sandbox
|
package sandbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -113,7 +114,12 @@ func convertPBFile(i stage.CmdFile) *pb.Request_File {
|
||||||
i.Src = &absPath
|
i.Src = &absPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &pb.Request_File{File: &pb.Request_File_Local{Local: &pb.Request_LocalFile{Src: *i.Src}}}
|
s, err := os.ReadFile(*i.Src)
|
||||||
|
if err != nil {
|
||||||
|
s = []byte{}
|
||||||
|
slog.Error("read file error", "path", *i.Src, "error", err)
|
||||||
|
}
|
||||||
|
return &pb.Request_File{File: &pb.Request_File_Memory{Memory: &pb.Request_MemoryFile{Content: s}}}
|
||||||
case i.Content != nil:
|
case i.Content != nil:
|
||||||
s := strToBytes(*i.Content)
|
s := strToBytes(*i.Content)
|
||||||
return &pb.Request_File{File: &pb.Request_File_Memory{Memory: &pb.Request_MemoryFile{Content: s}}}
|
return &pb.Request_File{File: &pb.Request_File_Memory{Memory: &pb.Request_MemoryFile{Content: s}}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user