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 c0b97d0485
Prevent double use of `git cat-file` session. (#29298) (#29301)
Backport #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.
1 year ago
..
e2e Change green buttons to primary color (#27099) 1 year ago
fuzz Rework markup link rendering (#26745) (#28803) 1 year ago
gitea-lfs-meta Test views of LFS files (#22196) 2 years ago
gitea-repositories-meta Fix reverting a merge commit failing (#28794) (#28825) 1 year ago
integration Prevent double use of `git cat-file` session. (#29298) (#29301) 1 year ago
testdata/data/attachments/a/0 Allow get release download files and lfs files with oauth2 token format (#26430) (#27379) 1 year ago
mssql.ini.tmpl Remove duplicated notify mail configuration on tests (#26912) 1 year ago
mysql.ini.tmpl Remove duplicated notify mail configuration on tests (#26912) 1 year ago
mysql8.ini.tmpl Do not use deprecated log config options by default (#26592) 2 years ago
pgsql.ini.tmpl Remove duplicated notify mail configuration on tests (#26912) 1 year ago
sqlite.ini.tmpl Do not use deprecated log config options by default (#26592) 2 years ago
test_utils.go Allow get release download files and lfs files with oauth2 token format (#26430) (#27379) 1 year ago