diff options
author | zeripath <art27@cantab.net> | 2021-07-22 12:53:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-22 12:53:54 +0100 |
commit | 1ce4fb256f43bb82c3b78a1cd7de87cc32690dc1 (patch) | |
tree | 9e994f7268b73d998f47ee2dc38626662c48c54b /models | |
parent | 9f02d1c3c00aef53cad7acdc51d861656edfbffd (diff) | |
download | gitea-1ce4fb256f43bb82c3b78a1cd7de87cc32690dc1.tar.gz gitea-1ce4fb256f43bb82c3b78a1cd7de87cc32690dc1.zip |
Restore creation of git-daemon-export-ok files (#16508)
Somewhere along the line the creation of git-daemon-export-ok
files disappeared but the updating of these files when
repo visibility changes remained. The problem is that the
current state will create files even when the org or user
is private.
This PR restores creation correctly.
Fix #15521
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go index d6abc1b5e3..de8a282531 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1152,6 +1152,16 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, overwriteO return fmt.Errorf("recalculateAccesses: %v", err) } + if u.Visibility == api.VisibleTypePublic && !repo.IsPrivate { + // Create/Remove git-daemon-export-ok for git-daemon... + daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`) + if f, err := os.Create(daemonExportFile); err != nil { + log.Error("Failed to create %s: %v", daemonExportFile, err) + } else { + f.Close() + } + } + if setting.Service.AutoWatchNewRepos { if err = watchRepo(ctx.e, doer.ID, repo.ID, true); err != nil { return fmt.Errorf("watchRepo: %v", err) @@ -1310,15 +1320,16 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e // Create/Remove git-daemon-export-ok for git-daemon... daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`) isExist, err := util.IsExist(daemonExportFile) + isPublic := !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePublic if err != nil { log.Error("Unable to check if %s exists. Error: %v", daemonExportFile, err) return err } - if repo.IsPrivate && isExist { + if !isPublic && isExist { if err = util.Remove(daemonExportFile); err != nil { log.Error("Failed to remove %s: %v", daemonExportFile, err) } - } else if !repo.IsPrivate && !isExist { + } else if isPublic && !isExist { if f, err := os.Create(daemonExportFile); err != nil { log.Error("Failed to create %s: %v", daemonExportFile, err) } else { |