mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Merge pull request #1401 from Zillode/fix-chmod-android
Fix chmod android
This commit is contained in:
commit
815e538f10
@ -718,13 +718,14 @@ func (p *Puller) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := sharedPullerState{
|
s := sharedPullerState{
|
||||||
file: file,
|
file: file,
|
||||||
folder: p.folder,
|
folder: p.folder,
|
||||||
tempName: tempName,
|
tempName: tempName,
|
||||||
realName: realName,
|
realName: realName,
|
||||||
copyTotal: len(blocks),
|
copyTotal: len(blocks),
|
||||||
copyNeeded: len(blocks),
|
copyNeeded: len(blocks),
|
||||||
reused: reused,
|
reused: reused,
|
||||||
|
ignorePerms: p.ignorePerms,
|
||||||
}
|
}
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
|
@ -29,11 +29,12 @@ import (
|
|||||||
// updated along the way.
|
// updated along the way.
|
||||||
type sharedPullerState struct {
|
type sharedPullerState struct {
|
||||||
// Immutable, does not require locking
|
// Immutable, does not require locking
|
||||||
file protocol.FileInfo
|
file protocol.FileInfo
|
||||||
folder string
|
folder string
|
||||||
tempName string
|
tempName string
|
||||||
realName string
|
realName string
|
||||||
reused int // Number of blocks reused from temporary file
|
reused int // Number of blocks reused from temporary file
|
||||||
|
ignorePerms bool
|
||||||
|
|
||||||
// Mutable, must be locked for access
|
// Mutable, must be locked for access
|
||||||
err error // The first error we hit
|
err error // The first error we hit
|
||||||
@ -96,7 +97,7 @@ func (s *sharedPullerState) tempFile() (io.WriterAt, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
} else if info.Mode()&0200 == 0 {
|
} else if info.Mode()&0200 == 0 {
|
||||||
err := os.Chmod(dir, 0755)
|
err := os.Chmod(dir, 0755)
|
||||||
if err == nil {
|
if !s.ignorePerms && err == nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
err := os.Chmod(dir, info.Mode().Perm())
|
err := os.Chmod(dir, info.Mode().Perm())
|
||||||
if err != nil {
|
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
|
// 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.
|
// make sure we have write permissions on the file before opening it.
|
||||||
err := os.Chmod(s.tempName, 0644)
|
err := os.Chmod(s.tempName, 0644)
|
||||||
if err != nil {
|
if !s.ignorePerms && err != nil {
|
||||||
s.failLocked("dst create chmod", err)
|
s.failLocked("dst create chmod", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func generateFiles(dir string, files, maxexp int, srcname string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = os.Chmod(p1, os.FileMode(rand.Intn(0777)|0400))
|
err = os.Chmod(p1, os.FileMode(rand.Intn(0777)|0400))
|
||||||
if err != nil {
|
if !ignorePerms && err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ func alterFiles(dir string) error {
|
|||||||
if info.Mode()&0200 != 0200 {
|
if info.Mode()&0200 != 0200 {
|
||||||
// Not owner writable. Fix.
|
// Not owner writable. Fix.
|
||||||
err = os.Chmod(path, 0644)
|
err = os.Chmod(path, 0644)
|
||||||
if err != nil {
|
if !ignorePerms && err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user