Closed
Description
- Gitea version (or commit ref): master
- Git version: recent - supports LFS
- Operating system: OSX (same issue on Linux)
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- [ X ] SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- [ X ] No
- Not relevant
- Log gist:
2017/03/16 20:58:15 [D] KUBA token claims ok
2017/03/16 20:58:15 [D] KUBA token requireWrite: %!i(bool=true)
2017/03/16 20:58:15 [D] KUBA token opStr: upload 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7
2017/03/16 20:58:15 [D] KUBA after token
2017/03/16 20:58:15 [D] LFS request - Method: POST, URL: /kuba/test1.git/info/lfs/objects, Status 401
2017/03/16 20:58:15 [D] LFS request - Method: POST, URL: /kuba/test1.git/info/lfs/objects, Status 202
(it has some additional debugging info I added)
Description
git push with LFS enabled fails with 401 error.
I traced it precisely to this statement:
if requireWrite && opStr != "upload" {
return false
}
in modules/lfs/server.go
The opStr being passed does not equal to "upload" but it begins with "upload" - with space and cryptic hex after.
Sample opStr:
upload 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7
I'm not sure which component generates the hex stuff after upload, if it's LFS client - I might have an older version (that works OK with github LFS and git-lfs-s3 (s3 backed)).
I'm not an expert in Go, but to solve this exact issue, I did the following change:
if requireWrite && strings.Split(opStr," ")[0] != "upload" {
return false
}
This ensures that if the opStr happens to have something additional following "upload" - it works without failing.
I'd be happy to submit a pull request if anybody could verify whether this makes any sense.