-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown files cannot be edited #15932
Comments
Click Edit to stay stuck in this interface |
Check the browser console for any errors. |
I didn't see any errors |
Works fine for me when I edit one of the files I can access. Might be a browser cache problem of you had visited before, try clearing it or |
This is not true for all files, but only for some. |
When I delete parts of the file, I can open the edit page again |
I forked your repo and indeed that seems to be some issue with the |
I updated my repo:https://try.gitea.io/FreeSaltedFish/test Test1.md is only one line more than test2.md. Test3.md is only one more '\n' than test2.md Is it caused by some special sequence of bytes? |
This is a really weird one. edit: I bisected, 270aab4 is the bad commit (from PR #15667) |
Will this bug be fixed in the next version? |
@FreeSaltedFish The bug didn't exist in the last release, this only happens in the current development version. So yes, we try to not introduce new bugs in releases, but can't give any guarantee. Feel free to look into it yourself if you want to get it fixed asap. @zeripath I studied your changes in your
Could you take a look on this? For reference, here we call to read the file Lines 104 to 125 in fb6c689
which is similar to the (working) codepath for viewing a file: Line 497 in fb6c689
|
There's not really any ordering as writes and reads shouldn't really be Asynchronous writes and reads. I guess I might have missed one? I'd have to replicate and test. The trick might be to re-get the cat-file-batch triple before use as there's a simple check if anything is buffered. |
Ah - I think there might actually be an issue here! The Close! |
hmm... still can't replicate this. From ee9f0a3970d5e5a91f236b25672fa24a79d7ac27 Mon Sep 17 00:00:00 2001
From: Andrew Thornton <[email protected]>
Date: Sat, 29 May 2021 19:41:29 +0100
Subject: [PATCH] Close the dataRC reader sooner
Fix #15932
Signed-off-by: Andrew Thornton <[email protected]>
---
routers/repo/editor.go | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/routers/repo/editor.go b/routers/repo/editor.go
index 2cc5c1e7f..3b74373c2 100644
--- a/routers/repo/editor.go
+++ b/routers/repo/editor.go
@@ -106,7 +106,13 @@ func editFile(ctx *context.Context, isNewFile bool) {
ctx.NotFound("blob.Data", err)
return
}
- defer dataRc.Close()
+ closed := false
+
+ defer func() {
+ if !closed {
+ dataRc.Close()
+ }
+ }()
ctx.Data["FileSize"] = blob.Size()
ctx.Data["FileName"] = blob.Name()
@@ -122,6 +128,11 @@ func editFile(ctx *context.Context, isNewFile bool) {
}
d, _ := ioutil.ReadAll(dataRc)
+ if err := dataRc.Close(); err != nil {
+ log.Error("Error whilst closing blob data: %v", err)
+ }
+ closed = true
+
buf = append(buf, d...)
if content, err := charset.ToUTF8WithErr(buf); err != nil {
log.Error("ToUTF8WithErr: %v", err)
--
2.31.1
Could you try applying the above patch to see if that solves your issue? (if copying&pasting you may need to add a blank line at the end) |
@zeripath yeah nice, that fixes it! |
Fix go-gitea#15932 Signed-off-by: Andrew Thornton <[email protected]>
Strange that I can't replicate. There must be a race but I don't quite understand how. |
Fix #15932 Signed-off-by: Andrew Thornton <[email protected]>
Fix go-gitea#15932 Signed-off-by: Andrew Thornton <[email protected]>
Gitea version (or commit ref): docker 1.15.0+dev-327-gc636ef8f1
Git version:
Operating system: centos 7
Database (use
[x]
):Can you reproduce the bug at https://try.gitea.io:
The text was updated successfully, but these errors were encountered: