From 871cc6f1b166fcef24d1ff09c7ed903ae105ff14 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 26 Dec 2015 17:42:37 -0800 Subject: [PATCH] call flush after files rm License: MIT Signed-off-by: Jeromy --- core/commands/files/files.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/commands/files/files.go b/core/commands/files/files.go index 2bb585374..f159e56c9 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -659,6 +659,17 @@ remove files or directories dashr, _, _ := req.Option("r").Bool() + var success bool + defer func() { + if success { + err := pdir.Flush() + if err != nil { + res.SetError(err, cmds.ErrNormal) + return + } + } + }() + // if '-r' specified, don't check file type (in bad scenarios, the block may not exist) if dashr { err := pdir.Unlink(name) @@ -667,6 +678,7 @@ remove files or directories return } + success = true return } @@ -686,6 +698,8 @@ remove files or directories res.SetError(err, cmds.ErrNormal) return } + + success = true } }, }