mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 11:28:59 +00:00
This commit is contained in:
parent
87780a5b7e
commit
5419ff9a71
@ -94,9 +94,6 @@ func (p *Puller) Serve() {
|
|||||||
|
|
||||||
var prevVer uint64
|
var prevVer uint64
|
||||||
|
|
||||||
// Clean out old temporaries before we start pulling
|
|
||||||
p.clean()
|
|
||||||
|
|
||||||
// We don't start pulling files until a scan has been completed.
|
// We don't start pulling files until a scan has been completed.
|
||||||
initialScanCompleted := false
|
initialScanCompleted := false
|
||||||
|
|
||||||
@ -131,6 +128,9 @@ loop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clean out old temporaries before we start pulling
|
||||||
|
p.clean()
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugln(p, "pulling", prevVer, curVer)
|
l.Debugln(p, "pulling", prevVer, curVer)
|
||||||
}
|
}
|
||||||
@ -649,14 +649,12 @@ func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
|
|||||||
// Verify the file against expected hashes
|
// Verify the file against expected hashes
|
||||||
fd, err := os.Open(state.tempName)
|
fd, err := os.Open(state.tempName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", err)
|
l.Warnln("puller: final:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = scanner.Verify(fd, protocol.BlockSize, state.file.Blocks)
|
err = scanner.Verify(fd, protocol.BlockSize, state.file.Blocks)
|
||||||
fd.Close()
|
fd.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", state.file.Name, err)
|
l.Warnln("puller: final:", state.file.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -665,7 +663,6 @@ func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
|
|||||||
if !p.ignorePerms {
|
if !p.ignorePerms {
|
||||||
err = os.Chmod(state.tempName, os.FileMode(state.file.Flags&0777))
|
err = os.Chmod(state.tempName, os.FileMode(state.file.Flags&0777))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", err)
|
l.Warnln("puller: final:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -682,7 +679,6 @@ func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
|
|||||||
// sync.
|
// sync.
|
||||||
l.Infof("Puller (folder %q, file %q): final: %v (continuing anyway as requested)", p.folder, state.file.Name, err)
|
l.Infof("Puller (folder %q, file %q): final: %v (continuing anyway as requested)", p.folder, state.file.Name, err)
|
||||||
} else {
|
} else {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", err)
|
l.Warnln("puller: final:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -694,7 +690,6 @@ func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
|
|||||||
if p.versioner != nil {
|
if p.versioner != nil {
|
||||||
err = p.versioner.Archive(state.realName)
|
err = p.versioner.Archive(state.realName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", err)
|
l.Warnln("puller: final:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -703,7 +698,6 @@ func (p *Puller) finisherRoutine(in <-chan *sharedPullerState) {
|
|||||||
// Replace the original file with the new one
|
// Replace the original file with the new one
|
||||||
err = osutil.Rename(state.tempName, state.realName)
|
err = osutil.Rename(state.tempName, state.realName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(state.tempName)
|
|
||||||
l.Warnln("puller: final:", err)
|
l.Warnln("puller: final:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user