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

Clean repository ROOT directory name with filepath.Clean #2846

Merged
merged 2 commits into from
Nov 4, 2017

Conversation

MCF
Copy link
Contributor

@MCF MCF commented Nov 4, 2017

For better compatibility with Windows.

Allows UNC paths for the repository ROOT. Fixes: #2845

@codecov-io
Copy link

codecov-io commented Nov 4, 2017

Codecov Report

Merging #2846 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2846   +/-   ##
=======================================
  Coverage   26.85%   26.85%           
=======================================
  Files          89       89           
  Lines       17607    17607           
=======================================
  Hits         4728     4728           
  Misses      12193    12193           
  Partials      686      686

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 d91fe52...587f0b6. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 4, 2017
@MCF
Copy link
Contributor Author

MCF commented Nov 4, 2017

FWIW I'm already running this patch in a windows production environment. Although I applied it to the release/V1.2 branch in that case. I'm happy to provide a backport to that branch if/when this PR is accepted.

@@ -973,7 +973,7 @@ func NewContext() {
if !filepath.IsAbs(RepoRootPath) {
RepoRootPath = path.Join(AppWorkPath, RepoRootPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change also here to filepath.Join so that behaviour is the same in both cases

@lafriks lafriks added this to the 1.3.0 milestone Nov 4, 2017
For better compatibility with Windows.
@MCF
Copy link
Contributor Author

MCF commented Nov 4, 2017

@lafriks I've made the change you requested.

I think it is important to clarify that only filepath.Clean is really important in the context of paths based on settings that come out of app.ini. As mentioned in the related issue #2845, app.ini only allows front slashes in the repository ROOT setting. This is enforced by forcePathSeparator, which is used for a number of other settings:

$ grep forcePathSeparator modules/setting/setting.go 
func forcePathSeparator(path string) {
	forcePathSeparator(LogRootPath)
	forcePathSeparator(RepoRootPath)
	forcePathSeparator(AvatarUploadPath)

As a result the calls to path.Join vs. filepath.Join don't matter so much in this context. For example:

[repository]
ROOT = store/repos    ; front slash required.

On Windows with the a GITEA work dir of C:\gitea the resulting paths would be:

filepath.Join C:\gitea\store/repos
path.Join C:\gitea/store/repos

Fortunately either variant works with go's file and directory functions. Go seems very forgiving when it comes to this sort of problem and seems to accept either slash in path names on Windows.

TL;DR I don't think we have to worry about path.Join, only path.Clean when it comes to UNC file system paths (or any other file paths) on Windows.

@lafriks
Copy link
Member

lafriks commented Nov 4, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 4, 2017
@Morlinest
Copy link
Member

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 4, 2017
@lafriks lafriks merged commit be52315 into go-gitea:master Nov 4, 2017
@MCF MCF deleted the unc_fix branch November 10, 2017 16:11
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows UNC paths do not work for some config settings
5 participants