Remove orphaned temp files before attempting to remove directories (fixes #492)

This commit is contained in:
Jakob Borg 2014-09-07 21:29:06 +02:00
parent 64ffac5671
commit 0a70e0b7b6

View File

@ -222,7 +222,7 @@ func (p *puller) run() {
if changed {
p.model.setState(p.repoCfg.ID, RepoCleaning)
p.fixupDirectories()
p.clean()
changed = false
}
@ -261,7 +261,9 @@ func (p *puller) runRO() {
}
}
func (p *puller) fixupDirectories() {
// clean deletes orphaned temporary files and directories that should no
// longer exist.
func (p *puller) clean() {
var deleteDirs []string
var changed = 0
@ -270,6 +272,10 @@ func (p *puller) fixupDirectories() {
return err
}
if info.Mode().IsRegular() && defTempNamer.IsTemporary(path) {
os.Remove(path)
}
if !info.IsDir() {
return nil
}