From bd11d3cb62e13b1760a45ef9261cdd954c07df3f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 14 Jan 2019 12:07:25 +0000 Subject: [PATCH] vfs: Fix panic on rename with --dry-run set - fixes #2911 --- vfs/file.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vfs/file.go b/vfs/file.go index 47fdf22ab..eec001b86 100644 --- a/vfs/file.go +++ b/vfs/file.go @@ -123,6 +123,12 @@ func (f *File) rename(destDir *Dir, newName string) error { fs.Errorf(f.Path(), "File.Rename error: %v", err) return err } + // newObject can be nil here for example if --dry-run + if newObject == nil { + err = errors.New("rename failed: nil object returned") + fs.Errorf(f.Path(), "File.Rename %v", err) + return err + } // Update the node with the new details fs.Debugf(f.o, "Updating file with %v %p", newObject, f) // f.rename(destDir, newObject)