feat: use CopyInDir instead of CopyInCwd

This commit is contained in:
张泊明518370910136 2024-09-22 01:36:07 -04:00
parent b7a1ad0833
commit a66dbc29e4
GPG Key ID: D47306D7062CDA9D
21 changed files with 26 additions and 24 deletions

View File

@ -75,7 +75,7 @@ Check `Cmd` at <https://github.com/criyle/go-judge#rest-api-interface>.
Some difference:
- `CopyInCwd bool`: set to `true` to add everything in the current working directory to `CopyIn`.
- `CopyInDir string`: set to non-empty string to add everything in that directory to `CopyIn`.
- `CopyInCached map[string]string`: key: file name in the sandbox, value: file name used in `CopyOutCached`.
- `LocalFile`: now supports the relative path

@ -1 +1 @@
Subproject commit 235d1980bb55c8ec231ab03933cf8e8335344b81
Subproject commit 30b179812335b427a431c303ed3453779f898796

@ -1 +1 @@
Subproject commit fc02680432a9003d623970187acce73276ce03b5
Subproject commit b16b4a9679bb97d8703a3c70d3b75dd06e9fd4df

@ -1 +1 @@
Subproject commit 3a0760f2442723eb77eafacbf89b0d25d62eb607
Subproject commit ca21e3ef7980339e433c6531d8e2aae9678eff2d

@ -1 +1 @@
Subproject commit 578be035a0aedc0d9b5ffe5f40d4162e6483b6d0
Subproject commit 866e73258c2d8f87b0000754a16f9b9c7de0c0fa

@ -1 +1 @@
Subproject commit 80ec230f63267a10777ae58ebb632709fc562e85
Subproject commit af355d91abf1ed62f19e0703dad55d18eb1252f8

@ -1 +1 @@
Subproject commit 13a3d05163213ce44c1ec638d4a409ed9db90530
Subproject commit cc5d991cb401b0c8cfd8e03a76fb9994158d2819

@ -1 +1 @@
Subproject commit 7f6f6e881d39e870e51afb3fd36fdbef20b9cb35
Subproject commit f29fbdac51f851e782f0db13f8640c6ba0aec49d

@ -1 +1 @@
Subproject commit 1492b43605a17850071d4e6674151719ae55e761
Subproject commit 146b2f829a91594c89f1d1379d312b91c5f97a55

@ -1 +1 @@
Subproject commit f2848d61097578d2439d3995820ea02a96ccad67
Subproject commit ffd9ab13c7e403d0afc7f1dfc86ec131f9992498

@ -1 +1 @@
Subproject commit 02de953cbc841afb3f53d0d4096b423f91d78593
Subproject commit b93a0254c2842e4d9c3a4b8f832cd6b17bf284f9

@ -1 +1 @@
Subproject commit 3161962adba8d6f2663963eb5c39578cb7874ab8
Subproject commit b4693716ee97bd5d9814c512b036aabeb12c7fd6

@ -1 +1 @@
Subproject commit 01b362e3bd5156211f8152237b101301560433b8
Subproject commit 50ec9ccbb6d7fe9b5352a018b6ac6445ac5c354f

@ -1 +1 @@
Subproject commit 0648e32a8932e561e102f336766ca18165866ab8
Subproject commit 9c010a0f8d501223f94d677a4aed70f0162092e2

@ -1 +1 @@
Subproject commit 5e25b932fc3950f382c8533e018520b04542af4a
Subproject commit 99d95c2841517f36a2063c641ea2e1b9b6190c76

@ -1 +1 @@
Subproject commit 1f53f4df209662a30f7005a925fff0f0e3d94b13
Subproject commit 1f962c75faccc9e703a8cd46e0a939551306bd4c

@ -1 +1 @@
Subproject commit 244a63f54397196f9f9a08114f4eef279093f2a6
Subproject commit 507ae70e81c08a6becdc8219a2c62b5aa8c3db69

@ -1 +1 @@
Subproject commit 980baf11df313e659fb4b1dea1a126add15ac547
Subproject commit 31b319157fb221636fcdf8d6a752a4a5e46d6a6d

@ -1 +1 @@
Subproject commit 1d886f8754d0a22471405580d231b2691b929bfd
Subproject commit 7a98095a322419939bffa8636207090493108a3c

View File

@ -28,7 +28,7 @@ func convertPBCmd(cmd []stage.Cmd) []*pb.Request_CmdType {
CpuSetLimit: c.CPUSetLimit,
DataSegmentLimit: c.DataSegmentLimit,
AddressSpaceLimit: c.AddressSpaceLimit,
CopyIn: convertPBCopyIn(c.CopyIn, c.CopyInCwd),
CopyIn: convertPBCopyIn(c.CopyIn, c.CopyInDir),
CopyOut: convertPBCopyOut(c.CopyOut),
CopyOutCached: convertPBCopyOut(c.CopyOutCached),
CopyOutMax: c.CopyOutMax,
@ -39,9 +39,11 @@ func convertPBCmd(cmd []stage.Cmd) []*pb.Request_CmdType {
return ret
}
func convertPBCopyIn(copyIn map[string]stage.CmdFile, copyInCwd bool) map[string]*pb.Request_File {
if copyInCwd {
_ = filepath.Walk(".",
func convertPBCopyIn(
copyIn map[string]stage.CmdFile, copyInDir string,
) map[string]*pb.Request_File {
if copyInDir != "" {
_ = filepath.Walk(copyInDir,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil

View File

@ -46,7 +46,7 @@ type Cmd struct {
CopyIn map[string]CmdFile `json:"copyIn"`
CopyInCached map[string]string `json:"copyInCached"`
CopyInCwd bool `json:"copyInCwd"`
CopyInDir string `json:"copyInDir"`
CopyOut []string `json:"copyOut"`
CopyOutCached []string `json:"copyOutCached"`