From 0a70e0b7b67ef114e4a64227facbeb09aa634bcc Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 7 Sep 2014 21:29:06 +0200 Subject: [PATCH] Remove orphaned temp files before attempting to remove directories (fixes #492) --- model/puller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/model/puller.go b/model/puller.go index 6b0edc21d..0024fba3f 100644 --- a/model/puller.go +++ b/model/puller.go @@ -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 }