aboutsummaryrefslogtreecommitdiffstats
path: root/models/dbfs
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2024-06-11 20:47:45 +0200
committerGitHub <noreply@github.com>2024-06-11 18:47:45 +0000
commitfc2d75f86d77b022ece848acf2581c14ef21d43b (patch)
treec95effed84f093643d8408b7cd32123a1114962d /models/dbfs
parent4bf848a06bfa069e5f381235193924f2b35f2d9d (diff)
downloadgitea-fc2d75f86d77b022ece848acf2581c14ef21d43b.tar.gz
gitea-fc2d75f86d77b022ece848acf2581c14ef21d43b.zip
Enable `unparam` linter (#31277)
Enable [unparam](https://github.com/mvdan/unparam) linter. Often I could not tell the intention why param is unused, so I put `//nolint` for those cases like webhook request creation functions never using `ctx`. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/dbfs')
-rw-r--r--models/dbfs/dbfile.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/models/dbfs/dbfile.go b/models/dbfs/dbfile.go
index 3650ce057e..dd27b5c36b 100644
--- a/models/dbfs/dbfile.go
+++ b/models/dbfs/dbfile.go
@@ -215,16 +215,15 @@ func fileTimestampToTime(timestamp int64) time.Time {
return time.UnixMicro(timestamp)
}
-func (f *file) loadMetaByPath() (*dbfsMeta, error) {
+func (f *file) loadMetaByPath() error {
var fileMeta dbfsMeta
if ok, err := db.GetEngine(f.ctx).Where("full_path = ?", f.fullPath).Get(&fileMeta); err != nil {
- return nil, err
+ return err
} else if ok {
f.metaID = fileMeta.ID
f.blockSize = fileMeta.BlockSize
- return &fileMeta, nil
}
- return nil, nil
+ return nil
}
func (f *file) open(flag int) (err error) {
@@ -288,10 +287,7 @@ func (f *file) createEmpty() error {
if err != nil {
return err
}
- if _, err = f.loadMetaByPath(); err != nil {
- return err
- }
- return nil
+ return f.loadMetaByPath()
}
func (f *file) truncate() error {
@@ -368,8 +364,5 @@ func buildPath(path string) string {
func newDbFile(ctx context.Context, path string) (*file, error) {
path = buildPath(path)
f := &file{ctx: ctx, fullPath: path, blockSize: defaultFileBlockSize}
- if _, err := f.loadMetaByPath(); err != nil {
- return nil, err
- }
- return f, nil
+ return f, f.loadMetaByPath()
}