Do not error when chmod failes when permissions are ignored (fixes #1404).

This commit is contained in:
Lode Hoste
2015-03-05 22:13:31 +01:00
parent 6057138466
commit 758233f001
3 changed files with 18 additions and 16 deletions

View File

@@ -29,11 +29,12 @@ import (
// updated along the way.
type sharedPullerState struct {
// Immutable, does not require locking
file protocol.FileInfo
folder string
tempName string
realName string
reused int // Number of blocks reused from temporary file
file protocol.FileInfo
folder string
tempName string
realName string
reused int // Number of blocks reused from temporary file
ignorePerms bool
// Mutable, must be locked for access
err error // The first error we hit
@@ -96,7 +97,7 @@ func (s *sharedPullerState) tempFile() (io.WriterAt, error) {
return nil, err
} else if info.Mode()&0200 == 0 {
err := os.Chmod(dir, 0755)
if err == nil {
if !s.ignorePerms && err == nil {
defer func() {
err := os.Chmod(dir, info.Mode().Perm())
if err != nil {
@@ -117,7 +118,7 @@ func (s *sharedPullerState) tempFile() (io.WriterAt, error) {
// file that we're going to try to reuse. To handle that, we need to
// make sure we have write permissions on the file before opening it.
err := os.Chmod(s.tempName, 0644)
if err != nil {
if !s.ignorePerms && err != nil {
s.failLocked("dst create chmod", err)
return nil, err
}