mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-08 05:39:21 +02:00
Fix empty binary content after move
This commit is contained in:
1 parent
07845a262d
commit
6f3b69b900
4 files changed
+78
-18
No files matched your search
@@ -145,10 +145,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
}
|
||||
|
||||
blob := entry.Blob()
|
||||
if blob.Size() >= setting.UI.MaxDisplayFileSize {
|
||||
ctx.NotFound(err)
|
||||
return
|
||||
}
|
||||
|
||||
buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob)
|
||||
if err != nil {
|
||||
@@ -303,6 +299,11 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
|
||||
operation = "create"
|
||||
}
|
||||
|
||||
var contentReader io.ReadSeeker
|
||||
if isNewFile && form.Content.Has() {
|
||||
contentReader = strings.NewReader(strings.ReplaceAll(form.Content.Value(), "\r", ""))
|
||||
}
|
||||
|
||||
if _, err := files_service.ChangeRepoFiles(ctx, ctx.Repo.Repository, ctx.Doer, &files_service.ChangeRepoFilesOptions{
|
||||
LastCommitID: form.LastCommit,
|
||||
OldBranch: ctx.Repo.BranchName,
|
||||
@@ -313,7 +314,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
|
||||
Operation: operation,
|
||||
FromTreePath: ctx.Repo.TreePath,
|
||||
TreePath: form.TreePath,
|
||||
ContentReader: strings.NewReader(strings.ReplaceAll(form.Content, "\r", "")),
|
||||
ContentReader: contentReader,
|
||||
},
|
||||
},
|
||||
Signoff: form.Signoff,
|
||||
|
||||
@@ -99,7 +99,7 @@ func NewDiffPatchPost(ctx *context.Context) {
|
||||
OldBranch: ctx.Repo.BranchName,
|
||||
NewBranch: branchName,
|
||||
Message: message,
|
||||
Content: strings.ReplaceAll(form.Content, "\r", ""),
|
||||
Content: strings.ReplaceAll(form.Content.Value(), "\r", ""),
|
||||
Author: gitCommitter,
|
||||
Committer: gitCommitter,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user