mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 09:31:53 +01:00 
			
		
		
		
	Backport #34356 by @bytedream It's possible to edit "raw" lfs files in the web UI when accessing the path manually.  Co-authored-by: bytedream <git@bytedream.dev>
This commit is contained in:
		
							parent
							
								
									6c5f0af45d
								
							
						
					
					
						commit
						b3f5196241
					
				| @ -20,7 +20,6 @@ import ( | |||||||
| 	"code.gitea.io/gitea/modules/markup" | 	"code.gitea.io/gitea/modules/markup" | ||||||
| 	"code.gitea.io/gitea/modules/setting" | 	"code.gitea.io/gitea/modules/setting" | ||||||
| 	"code.gitea.io/gitea/modules/templates" | 	"code.gitea.io/gitea/modules/templates" | ||||||
| 	"code.gitea.io/gitea/modules/typesniffer" |  | ||||||
| 	"code.gitea.io/gitea/modules/util" | 	"code.gitea.io/gitea/modules/util" | ||||||
| 	"code.gitea.io/gitea/modules/web" | 	"code.gitea.io/gitea/modules/web" | ||||||
| 	"code.gitea.io/gitea/routers/utils" | 	"code.gitea.io/gitea/routers/utils" | ||||||
| @ -151,9 +150,13 @@ func editFile(ctx *context.Context, isNewFile bool) { | |||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		dataRc, err := blob.DataAsync() | 		buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			ctx.NotFound(err) | 			if git.IsErrNotExist(err) { | ||||||
|  | 				ctx.NotFound(err) | ||||||
|  | 			} else { | ||||||
|  | 				ctx.ServerError("getFileReader", err) | ||||||
|  | 			} | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -161,12 +164,8 @@ func editFile(ctx *context.Context, isNewFile bool) { | |||||||
| 
 | 
 | ||||||
| 		ctx.Data["FileSize"] = blob.Size() | 		ctx.Data["FileSize"] = blob.Size() | ||||||
| 
 | 
 | ||||||
| 		buf := make([]byte, 1024) |  | ||||||
| 		n, _ := util.ReadAtMost(dataRc, buf) |  | ||||||
| 		buf = buf[:n] |  | ||||||
| 
 |  | ||||||
| 		// Only some file types are editable online as text. | 		// Only some file types are editable online as text. | ||||||
| 		if !typesniffer.DetectContentType(buf).IsRepresentableAsText() { | 		if !fInfo.isTextFile || fInfo.isLFSFile { | ||||||
| 			ctx.NotFound(nil) | 			ctx.NotFound(nil) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user