diff options
author | Joe Chen <jc@unknwon.io> | 2022-10-23 00:15:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 00:15:43 +0800 |
commit | 8077360cf6370c9ddb026f2432ceb4f4f4ac31c4 (patch) | |
tree | 29139ca7a9bf0cda055fc064f7afa43010ebf1d8 /internal/db/repo_editor.go | |
parent | 2e020b1cf656f9a87b1d8a5fe9792446e06343df (diff) |
chore(db): remove unused field (#7202)
Diffstat (limited to 'internal/db/repo_editor.go')
-rw-r--r-- | internal/db/repo_editor.go | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/internal/db/repo_editor.go b/internal/db/repo_editor.go index 98065d43..63c88b76 100644 --- a/internal/db/repo_editor.go +++ b/internal/db/repo_editor.go @@ -7,7 +7,6 @@ package db import ( "fmt" "io" - "io/ioutil" "mime/multipart" "os" "os/exec" @@ -109,14 +108,13 @@ func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error { } type UpdateRepoFileOptions struct { - LastCommitID string - OldBranch string - NewBranch string - OldTreeName string - NewTreeName string - Message string - Content string - IsNewFile bool + OldBranch string + NewBranch string + OldTreeName string + NewTreeName string + Message string + Content string + IsNewFile bool } // UpdateRepoFile adds or updates a file in repository. @@ -179,7 +177,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) ( } } - if err = ioutil.WriteFile(filePath, []byte(opts.Content), 0666); err != nil { + if err = os.WriteFile(filePath, []byte(opts.Content), 0600); err != nil { return fmt.Errorf("write file: %v", err) } @@ -225,7 +223,7 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff * if err = os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil { return nil, err } - if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil { + if err = os.WriteFile(filePath, []byte(content), 0600); err != nil { return nil, fmt.Errorf("write file: %v", err) } @@ -365,7 +363,7 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err if err != nil { return nil, fmt.Errorf("create: %v", err) } - defer fw.Close() + defer func() { _ = fw.Close() }() if _, err = fw.Write(buf); err != nil { return nil, fmt.Errorf("write: %v", err) |