summaryrefslogtreecommitdiffstats
path: root/models/dbfs/dbfs.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.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.go')
-rw-r--r--models/dbfs/dbfs.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/models/dbfs/dbfs.go b/models/dbfs/dbfs.go
index 6b5b3beeb2..f68b4a2b70 100644
--- a/models/dbfs/dbfs.go
+++ b/models/dbfs/dbfs.go
@@ -5,7 +5,10 @@ package dbfs
import (
"context"
+ "io/fs"
"os"
+ "path"
+ "time"
"code.gitea.io/gitea/models/db"
)
@@ -100,3 +103,29 @@ func Remove(ctx context.Context, name string) error {
defer f.Close()
return f.delete()
}
+
+var _ fs.FileInfo = (*dbfsMeta)(nil)
+
+func (m *dbfsMeta) Name() string {
+ return path.Base(m.FullPath)
+}
+
+func (m *dbfsMeta) Size() int64 {
+ return m.FileSize
+}
+
+func (m *dbfsMeta) Mode() fs.FileMode {
+ return os.ModePerm
+}
+
+func (m *dbfsMeta) ModTime() time.Time {
+ return fileTimestampToTime(m.ModifyTimestamp)
+}
+
+func (m *dbfsMeta) IsDir() bool {
+ return false
+}
+
+func (m *dbfsMeta) Sys() any {
+ return nil
+}