Skip to content
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

[help wanted] Get basic upload-to-wiki working #12279

Closed
wants to merge 3 commits into from

Conversation

BLumia
Copy link
Member

@BLumia BLumia commented Jul 20, 2020

Intended to resolve #574 , still WIP, not ready to merge.


I need this feature and find out there is an issue requesting this feature(#574), so would like to try to implement this feature. I tryed rebasing #6024 onto master but it seems there are too many changes from the codebase so I decided to reimplement the feature directly on master branch. Now the upload works but I do think what I did is probably not the correct way to implement it. I'll explain later.

Here are some WIP screenshots in current PR state:

Screenshots about file upload

wikipage
uploadpage

Reason about why I think my current implementation is bad is, when try to hacking on this feature, I found temp_repo.go always do operation to the repo when calling NewTemporaryUploadRepository(repo *models.Repository), seems I cannot operate to the wiki repo directly, so I added CloneWiki() and PushWiki() so I can process the wiki repo instead of the original repo. But I found inside PushingEnvironment() there are checks about if it is a wiki repo, so I think I may probably missed something.

The current PR state should be able to upload file to wiki repo, but after clicking the upload button, the page turns blank. I checked the console output and here is the related log:

UploadWikiFilePost
[Macaron] 2020-07-20 16:15:12: Started POST /api/internal/hook/pre-receive/blblb/61616 for [::1]
[Macaron] 2020-07-20 16:15:12: Completed POST /api/internal/hook/pre-receive/blblb/61616 200 OK in 2.9995ms
[Macaron] 2020-07-20 16:15:13: Started POST /api/internal/hook/post-receive/blblb/61616 for [::1]
[Macaron] 2020-07-20 16:15:13: Completed POST /api/internal/hook/post-receive/blblb/61616 500 Internal Server Error in 93.0008ms
[Macaron] 2020-07-20 16:15:13: Completed POST /blblb/61616/wiki/_upload 0  in 2.9386116s
[Macaron] 2020-07-20 16:15:13: Started GET /favicon.ico for 127.0.0.1
[Macaron] 2020-07-20 16:15:13: Completed GET /favicon.ico 304 Not Modified in 1.9981ms
[Macaron] 2020-07-20 16:15:15: Started GET /serviceworker.js for 127.0.0.1
[Macaron] [Static] Serving /serviceworker.js
[Macaron] 2020-07-20 16:15:15: Completed GET /serviceworker.js 304 Not Modified in 33.9743ms

I guess it is the 500 internal server error which caused the issue. I think it probably because I still missed something which cause it trigger the main repo post-receive hock, but still doesn't know where should I look at.

I still not dig into the whole codebase too deep (actually I'm new to golang), but still would like to help implementing this issue. Any advices / comments / code review would be very helpful. Thanks!

@BLumia BLumia mentioned this pull request Jul 20, 2020
@BLumia BLumia force-pushed the wiki-files-upload branch from e1e5349 to 40af980 Compare July 25, 2020 12:42
@BLumia
Copy link
Member Author

BLumia commented Jul 25, 2020

Last commit rebased the code onto the current master and fixed the git hook issue caused by provided a wrong env. There are still one issue haven't get resolved, after clicking the upload button, it will says "The process cannot access the file because it is being used by another process."(the file actually get into the wiki repo, but the cached file not get removed). Still don't know where went wrong..

Anyway although it's still WIP but I think maybe it can be good if someone can review the current state of this PR now so I can know where I did wrong to get me on the right track. Any review and advices are appreciated!

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 25, 2020
@BLumia BLumia marked this pull request as ready for review July 25, 2020 12:53
@BLumia BLumia force-pushed the wiki-files-upload branch 2 times, most recently from 7c4a716 to ba7d000 Compare August 3, 2020 15:21
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Aug 4, 2020
@BLumia BLumia force-pushed the wiki-files-upload branch from ba7d000 to 2cc55a2 Compare August 11, 2020 11:17
@BLumia BLumia force-pushed the wiki-files-upload branch from 2cc55a2 to 10b92f3 Compare August 23, 2020 05:33
@codecov-commenter
Copy link

Codecov Report

Merging #12279 into master will decrease coverage by 0.13%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12279      +/-   ##
==========================================
- Coverage   43.52%   43.38%   -0.14%     
==========================================
  Files         642      643       +1     
  Lines       71003    71239     +236     
==========================================
+ Hits        30904    30907       +3     
- Misses      35096    35322     +226     
- Partials     5003     5010       +7     
Impacted Files Coverage Δ
models/helper_environment.go 85.71% <0.00%> (-6.60%) ⬇️
modules/auth/repo_form.go 41.59% <0.00%> (-0.75%) ⬇️
modules/repofiles/upload.go 0.00% <0.00%> (ø)
routers/repo/repo.go 32.28% <0.00%> (-0.26%) ⬇️
routers/repo/wiki.go 37.44% <0.00%> (-3.74%) ⬇️
modules/repofiles/temp_repo.go 60.59% <52.63%> (-1.40%) ⬇️
routers/routes/routes.go 89.02% <100.00%> (+0.12%) ⬆️
services/wiki/wiki.go 56.90% <100.00%> (-1.39%) ⬇️
modules/auth/sso/oauth2.go 46.77% <0.00%> (-14.52%) ⬇️
modules/notification/mail/mail.go 32.50% <0.00%> (-3.75%) ⬇️
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e14f608...10b92f3. Read the comment docs.

@stale
Copy link

stale bot commented Nov 1, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions.

@stale stale bot added the issue/stale label Nov 1, 2020
@codecov-io
Copy link

codecov-io commented Nov 12, 2020

Codecov Report

Merging #12279 (9869872) into master (ccfa408) will decrease coverage by 0.05%.
The diff coverage is 19.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12279      +/-   ##
==========================================
- Coverage   42.24%   42.19%   -0.06%     
==========================================
  Files         710      710              
  Lines       77232    77310      +78     
==========================================
- Hits        32626    32618       -8     
- Misses      39241    39317      +76     
- Partials     5365     5375      +10     
Impacted Files Coverage Δ
models/helper_environment.go 87.50% <0.00%> (-5.84%) ⬇️
modules/auth/repo_form.go 39.16% <0.00%> (-0.67%) ⬇️
modules/repofiles/upload.go 0.00% <0.00%> (ø)
routers/repo/repo.go 32.23% <0.00%> (-0.41%) ⬇️
routers/repo/wiki.go 37.09% <0.00%> (-4.08%) ⬇️
modules/repofiles/temp_repo.go 58.46% <52.63%> (-1.19%) ⬇️
routers/routes/macaron.go 92.60% <100.00%> (+0.06%) ⬆️
services/wiki/wiki.go 57.21% <100.00%> (-1.33%) ⬇️
modules/indexer/stats/queue.go 52.94% <0.00%> (-23.53%) ⬇️
modules/indexer/stats/db.go 43.47% <0.00%> (-8.70%) ⬇️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc1cf6e...9869872. Read the comment docs.

@stale stale bot removed the issue/stale label Nov 12, 2020
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Nov 13, 2020
@BLumia BLumia changed the title WIP: get basic upload-to-wiki working [help wanted] Get basic upload-to-wiki working Dec 12, 2020
@6543 6543 added this to the 1.15.0 milestone Mar 1, 2021
@BLumia
Copy link
Member Author

BLumia commented Apr 16, 2021

Due to very limited spare time and the gitea development actually grows pretty fast, I may not have time to continue working on this feature. I'll close this PR and leave the patch here as a reference and see if anyone else would like to work on this feature.

This patch only added a place to upload image files to a _media folder to use, there is no place to browse a list of image files uploaded to the wiki repo. To improve the useability of the wiki feature, I think there are also some other things that need to be done other than just allow uploading image files, but that's more likely a major refactor then :/

Anyway hope the best :)

@BLumia BLumia closed this Apr 16, 2021
@go-gitea go-gitea locked and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uploads on the wiki
6 participants