Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/v1.14' into release/dc…
Browse files Browse the repository at this point in the history
…s/v1.14
  • Loading branch information
richmahn committed Jul 19, 2021
2 parents 8123c27 + e6c2225 commit d788a17
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .drone.yml
Expand Up @@ -709,7 +709,7 @@ steps:

- name: publish
pull: always
image: plugins/docker:linux-amd64
image: techknowlogick/drone-docker:latest
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
Expand All @@ -726,7 +726,7 @@ steps:
- pull_request

- name: publish-rootless
image: plugins/docker:linux-amd64
image: techknowlogick/drone-docker:latest
settings:
dockerfile: Dockerfile.rootless
auto_tag: true
Expand Down Expand Up @@ -764,7 +764,7 @@ trigger:
steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm64
image: techknowlogick/drone-docker:latest
settings:
dry_run: true
repo: gitea/gitea
Expand Down Expand Up @@ -806,7 +806,7 @@ steps:

- name: publish
pull: always
image: plugins/docker:linux-arm64
image: techknowlogick/drone-docker:latest
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
Expand All @@ -826,7 +826,7 @@ steps:
- pull_request

- name: publish-rootless
image: plugins/docker:linux-arm64
image: techknowlogick/drone-docker:latest
settings:
dockerfile: Dockerfile.rootless
auto_tag: true
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,18 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io).

## [1.14.5](https://github.com/go-gitea/gitea/releases/tag/v1.14.5) - 2021-07-16

* SECURITY
* Hide mirror passwords on repo settings page (#16022) (#16355)
* Update bluemonday to v1.0.15 (#16379) (#16380)
* BUGFIXES
* Retry rename on lock induced failures (#16435) (#16439)
* Validate issue index before querying DB (#16406) (#16410)
* Fix crash following ldap authentication update (#16447) (#16449)
* ENHANCEMENTS
* Redirect on bad CSRF instead of presenting bad page (#14937) (#16378)

## [1.14.4](https://github.com/go-gitea/gitea/releases/tag/v1.14.4) - 2021-07-06

* BUGFIXES
Expand Down
3 changes: 2 additions & 1 deletion cmd/embedded.go
Expand Up @@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/public"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/util"

"github.com/gobwas/glob"
"github.com/urfave/cli"
Expand Down Expand Up @@ -271,7 +272,7 @@ func extractAsset(d string, a asset, overwrite, rename bool) error {
} else if !fi.Mode().IsRegular() {
return fmt.Errorf("%s already exists, but it's not a regular file", dest)
} else if rename {
if err := os.Rename(dest, dest+".bak"); err != nil {
if err := util.Rename(dest, dest+".bak"); err != nil {
return fmt.Errorf("Error creating backup for %s: %v", dest, err)
}
// Attempt to respect file permissions mask (even if user:group will be set anew)
Expand Down
3 changes: 3 additions & 0 deletions models/issue.go
Expand Up @@ -1034,6 +1034,9 @@ func newIssueAttempt(repo *Repository, issue *Issue, labelIDs []int64, uuids []s

// GetIssueByIndex returns raw issue without loading attributes by index in a repository.
func GetIssueByIndex(repoID, index int64) (*Issue, error) {
if index < 1 {
return nil, ErrIssueNotExist{}
}
issue := &Issue{
RepoID: repoID,
Index: index,
Expand Down
4 changes: 2 additions & 2 deletions models/login_source.go
Expand Up @@ -73,9 +73,9 @@ var (
// possible that a Blob may gain an unwanted prefix of 0xff 0xfe.
func jsonUnmarshalIgnoreErroneousBOM(bs []byte, v interface{}) error {
json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal(bs, &v)
err := json.Unmarshal(bs, v)
if err != nil && len(bs) > 2 && bs[0] == 0xff && bs[1] == 0xfe {
err = json.Unmarshal(bs[2:], &v)
err = json.Unmarshal(bs[2:], v)
}
return err
}
Expand Down
4 changes: 2 additions & 2 deletions models/repo.go
Expand Up @@ -1221,7 +1221,7 @@ func ChangeRepositoryName(doer *User, repo *Repository, newRepoName string) (err
}

newRepoPath := RepoPath(repo.Owner.Name, newRepoName)
if err = os.Rename(repo.RepoPath(), newRepoPath); err != nil {
if err = util.Rename(repo.RepoPath(), newRepoPath); err != nil {
return fmt.Errorf("rename repository directory: %v", err)
}

Expand All @@ -1232,7 +1232,7 @@ func ChangeRepositoryName(doer *User, repo *Repository, newRepoName string) (err
return err
}
if isExist {
if err = os.Rename(wikiPath, WikiPath(repo.Owner.Name, newRepoName)); err != nil {
if err = util.Rename(wikiPath, WikiPath(repo.Owner.Name, newRepoName)); err != nil {
return fmt.Errorf("rename repository wiki: %v", err)
}
}
Expand Down
8 changes: 4 additions & 4 deletions models/repo_transfer.go
Expand Up @@ -210,13 +210,13 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
}

if repoRenamed {
if err := os.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil {
if err := util.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil {
log.Critical("Unable to move repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name), err)
}
}

if wikiRenamed {
if err := os.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil {
if err := util.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil {
log.Critical("Unable to move wiki for repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name), err)
}
}
Expand Down Expand Up @@ -358,7 +358,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}

if err := os.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
if err := util.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository directory: %v", err)
}
repoRenamed = true
Expand All @@ -370,7 +370,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e
log.Error("Unable to check if %s exists. Error: %v", wikiPath, err)
return err
} else if isExist {
if err := os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
if err := util.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
return fmt.Errorf("rename repository wiki: %v", err)
}
wikiRenamed = true
Expand Down
4 changes: 2 additions & 2 deletions models/ssh_key.go
Expand Up @@ -834,7 +834,7 @@ func rewriteAllPublicKeys(e Engine) error {
}

t.Close()
return os.Rename(tmpPath, fPath)
return util.Rename(tmpPath, fPath)
}

// RegeneratePublicKeys regenerates the authorized_keys file
Expand Down Expand Up @@ -1316,7 +1316,7 @@ func rewriteAllPrincipalKeys(e Engine) error {
}

t.Close()
return os.Rename(tmpPath, fPath)
return util.Rename(tmpPath, fPath)
}

// ListPrincipalKeys returns a list of principals belongs to given user.
Expand Down
4 changes: 2 additions & 2 deletions models/user.go
Expand Up @@ -1011,7 +1011,7 @@ func ChangeUserName(u *User, newUserName string) (err error) {
}

// Do not fail if directory does not exist
if err = os.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) {
if err = util.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Rename user directory: %v", err)
}

Expand All @@ -1020,7 +1020,7 @@ func ChangeUserName(u *User, newUserName string) (err error) {
}

if err = sess.Commit(); err != nil {
if err2 := os.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) {
if err2 := util.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) {
log.Critical("Unable to rollback directory change during failed username change from: %s to: %s. DB Error: %v. Filesystem Error: %v", oldUserName, newUserName, err, err2)
return fmt.Errorf("failed to rollback directory change during failed username change from: %s to: %s. DB Error: %w. Filesystem Error: %v", oldUserName, newUserName, err, err2)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/log/file.go
Expand Up @@ -177,7 +177,7 @@ func (log *FileLogger) DoRotate() error {

// close fd before rename
// Rename the file to its newfound home
if err = os.Rename(log.Filename, fname); err != nil {
if err = util.Rename(log.Filename, fname); err != nil {
return fmt.Errorf("Rotate: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion modules/storage/local.go
Expand Up @@ -96,7 +96,7 @@ func (l *LocalStorage) Save(path string, r io.Reader, size int64) (int64, error)
return 0, err
}

if err := os.Rename(tmp.Name(), p); err != nil {
if err := util.Rename(tmp.Name(), p); err != nil {
return 0, err
}

Expand Down
29 changes: 28 additions & 1 deletion modules/util/remove.go
Expand Up @@ -33,7 +33,7 @@ func Remove(name string) error {
return err
}

// RemoveAll removes the named file or (empty) directory with at most 5 attempts.Remove
// RemoveAll removes the named file or (empty) directory with at most 5 attempts.
func RemoveAll(name string) error {
var err error
for i := 0; i < 5; i++ {
Expand All @@ -55,3 +55,30 @@ func RemoveAll(name string) error {
}
return err
}

// Rename renames (moves) oldpath to newpath with at most 5 attempts.
func Rename(oldpath, newpath string) error {
var err error
for i := 0; i < 5; i++ {
err = os.Rename(oldpath, newpath)
if err == nil {
break
}
unwrapped := err.(*os.LinkError).Err
if unwrapped == syscall.EBUSY || unwrapped == syscall.ENOTEMPTY || unwrapped == syscall.EPERM || unwrapped == syscall.EMFILE || unwrapped == syscall.ENFILE {
// try again
<-time.After(100 * time.Millisecond)
continue
}

if i == 0 && os.IsNotExist(err) {
return err
}

if unwrapped == syscall.ENOENT {
// it's already gone
return nil
}
}
return err
}

0 comments on commit d788a17

Please sign in to comment.