1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-10 04:04:24 +00:00
gitea/routers/api/actions
FuXiaoHei ec0c6829d4
Fix/upload artifact error windows (#27802)
From issue https://github.com/go-gitea/gitea/issues/27314

When act_runner in `host` mode on Windows. `upload_artifact@v3` actions
use `path.join` to generate `itemPath` params when uploading artifact
chunk. `itemPath` is encoded as `${artifact_name}\${artifact_path}`.

<del>It's twice query escaped from ${artifact_name}/${artifact_path}
that joined by Windows slash \.</del>

**So we need convert Windows slash to linux**.

In https://github.com/go-gitea/gitea/issues/27314, runner shows logs
from `upload_artifact@v3` like with `%255C`:

```
[artifact-cases/test-artifact-cases]   | ::error::Unexpected response. Unable to upload chunk to http://192.168.31.230:3000/api/actions_pipeline/_apis/pipelines/workflows/6/artifacts/34d628a422db9367c869d3fb36be81f5/upload?itemPath=more-files%255Css.json
```

But in gitea server at the same time, But shows `%5C`

```
2023/10/27 19:29:51 ...eb/routing/logger.go:102:func1() [I] router: completed PUT /api/actions_pipeline/_apis/pipelines/workflows/6/artifacts/34d628a422db9367c869d3fb36be81f5/upload?itemPath=more-files%5Css.json for 192.168.31.230:55340, 400 Bad Request in 17.6ms @ <autogenerated>:1(actions.artifactRoutes.uploadArtifact-fm)
```

I found `%255C` is escaped by
`https://github.com/actions/upload-artifact/blob/main/dist/index.js#L2329`.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-10-30 10:40:05 +00:00
..
ping Implement actions (#21937) 2023-01-31 09:45:19 +08:00
runner Redefine the meaning of column is_active to make Actions Registration Token generation easier (#27143) 2023-09-27 05:37:48 +00:00
actions.go Refactor web package and context package (#25298) 2023-06-18 09:59:09 +02:00
artifacts_chunks.go Artifacts retention and auto clean up (#26131) 2023-09-06 07:41:06 +00:00
artifacts_utils.go Fix/upload artifact error windows (#27802) 2023-10-30 10:40:05 +00:00
artifacts.go Artifacts retention and auto clean up (#26131) 2023-09-06 07:41:06 +00:00