aboutsummaryrefslogtreecommitdiffstats
path: root/models/dbfs/dbfs_test.go
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-06-28 19:39:23 -0400
committerGitHub <noreply@github.com>2023-06-28 23:39:23 +0000
commit8981f6d0fc375c75ff5a2c1b6eb9e33c8dbaf722 (patch)
treefd44084c063364eac71476d9a1269c4375097e17 /models/dbfs/dbfs_test.go
parentb2b5c80cb23971691531a4caaf4255fa196da1df (diff)
downloadgitea-8981f6d0fc375c75ff5a2c1b6eb9e33c8dbaf722.tar.gz
gitea-8981f6d0fc375c75ff5a2c1b6eb9e33c8dbaf722.zip
Fix content holes in Actions task logs file (#25560) (#25566)
Backport #25560 by @wolfogre Fix #25451. Bugfixes: - When stopping the zombie or endless tasks, set `LogInStorage` to true after transferring the file to storage. It was missing, it could write to a nonexistent file in DBFS because `LogInStorage` was false. - Always update `ActionTask.Updated` when there's a new state reported by the runner, even if there's no change. This is to avoid the task being judged as a zombie task. Enhancement: - Support `Stat()` for DBFS file. - `WriteLogs` refuses to write if it could result in content holes. Co-authored-by: Jason Song <i@wolfogre.com>
Diffstat (limited to 'models/dbfs/dbfs_test.go')
-rw-r--r--models/dbfs/dbfs_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/dbfs/dbfs_test.go b/models/dbfs/dbfs_test.go
index 300758c623..96cb1014c7 100644
--- a/models/dbfs/dbfs_test.go
+++ b/models/dbfs/dbfs_test.go
@@ -111,6 +111,19 @@ func TestDbfsBasic(t *testing.T) {
_, err = OpenFile(db.DefaultContext, "test2.txt", os.O_RDONLY)
assert.Error(t, err)
+
+ // test stat
+ f, err = OpenFile(db.DefaultContext, "test/test.txt", os.O_RDWR|os.O_CREATE)
+ assert.NoError(t, err)
+ stat, err := f.Stat()
+ assert.NoError(t, err)
+ assert.EqualValues(t, "test.txt", stat.Name())
+ assert.EqualValues(t, 0, stat.Size())
+ _, err = f.Write([]byte("0123456789"))
+ assert.NoError(t, err)
+ stat, err = f.Stat()
+ assert.NoError(t, err)
+ assert.EqualValues(t, 10, stat.Size())
}
func TestDbfsReadWrite(t *testing.T) {