You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/tests
KN4CK3R f74c869221
Prevent double use of `git cat-file` session. (#29298)
Fixes the reason why #29101 is hard to replicate.
Related #29297

Create a repo with a file with minimum size 4097 bytes (I use 10000) and
execute the following code:
```go
gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, <repo>)
assert.NoError(t, err)

commit, err := gitRepo.GetCommit(<sha>)
assert.NoError(t, err)

entry, err := commit.GetTreeEntryByPath(<file>)
assert.NoError(t, err)

b := entry.Blob()

// Create a reader
r, err := b.DataAsync()
assert.NoError(t, err)
defer r.Close()

// Create a second reader
r2, err := b.DataAsync()
assert.NoError(t, err) // Should be no error but is ErrNotExist
defer r2.Close()
```

The problem is the check in `CatFileBatch`:

79217ea63c/modules/git/repo_base_nogogit.go (L81-L87)
`Buffered() > 0` is used to check if there is a "operation" in progress
at the moment. This is a problem because we can't control the internal
buffer in the `bufio.Reader`. The code above demonstrates a sequence
which initiates an operation for which the code thinks there is no
active processing. The second call to `DataAsync()` therefore reuses the
existing instances instead of creating a new batch reader.
11 months ago
..
e2e Require MySQL 8.0, PostgreSQL 12, MSSQL 2012 (#27337) 1 year ago
fuzz Rework markup link rendering (#26745) 1 year ago
gitea-lfs-meta Test views of LFS files (#22196) 2 years ago
gitea-repositories-meta tests: missing refs/ in bare repositories (#28844) 1 year ago
integration Prevent double use of `git cat-file` session. (#29298) 11 months ago
testdata/data/attachments/a/0 Allow get release download files and lfs files with oauth2 token format (#26430) 1 year ago
mssql.ini.tmpl Disable query token param in integration tests (#28592) 1 year ago
mysql.ini.tmpl Disable query token param in integration tests (#28592) 1 year ago
pgsql.ini.tmpl Disable query token param in integration tests (#28592) 1 year ago
sqlite.ini.tmpl Disable query token param in integration tests (#28592) 1 year ago
test_utils.go Allow get release download files and lfs files with oauth2 token format (#26430) 1 year ago