From fedfbfc5b344bb219a573ce5248a47e6af22c033 Mon Sep 17 00:00:00 2001 From: "Hasibul Hasan (Anik)" <25927971+AnikHasibul@users.noreply.github.com> Date: Tue, 7 May 2019 05:39:29 +0600 Subject: [PATCH 1/3] Remove unnecessary else block. --- Attrs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Attrs.go b/Attrs.go index 46cb869..bfd1248 100644 --- a/Attrs.go +++ b/Attrs.go @@ -48,7 +48,6 @@ func (this *Attrs) Attr(a *fuse.Attr) error { func (this *Attrs) FuseNodeType() fuse.DirentType { if (this.Mode & os.ModeDir) == os.ModeDir { return fuse.DT_Dir - } else { - return fuse.DT_File } + return fuse.DT_File } From 50d26666a8b56ba0d3d2f5e236a6a4ca9eb97b73 Mon Sep 17 00:00:00 2001 From: "Hasibul Hasan (Anik)" <25927971+AnikHasibul@users.noreply.github.com> Date: Tue, 7 May 2019 05:41:35 +0600 Subject: [PATCH 2/3] Remove unnecessary else block. --- Dir.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dir.go b/Dir.go index 173796e..9c2494e 100644 --- a/Dir.go +++ b/Dir.go @@ -36,9 +36,8 @@ var _ fs.NodeRenamer = (*Dir)(nil) func (this *Dir) AbsolutePath() string { if this.Parent == nil { return "/" - } else { - return path.Join(this.Parent.AbsolutePath(), this.Attrs.Name) } + return path.Join(this.Parent.AbsolutePath(), this.Attrs.Name) } // Returns absolute path of the child item of this directory @@ -79,7 +78,6 @@ func (this *Dir) EntriesSet(name string, node fs.Node) { if this.Entries == nil { this.Entries = make(map[string]fs.Node) } - this.Entries[name] = node } From 752d6cda01994c6a11cdadb035921d4da3552096 Mon Sep 17 00:00:00 2001 From: "Hasibul Hasan (Anik)" <25927971+AnikHasibul@users.noreply.github.com> Date: Tue, 7 May 2019 05:45:50 +0600 Subject: [PATCH 3/3] Unnecessary else block and used %v instead of %s for errors. --- FaultTolerantHdfsAccessor.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/FaultTolerantHdfsAccessor.go b/FaultTolerantHdfsAccessor.go index 74d6b04..64efa97 100644 --- a/FaultTolerantHdfsAccessor.go +++ b/FaultTolerantHdfsAccessor.go @@ -26,7 +26,7 @@ func (this *FaultTolerantHdfsAccessor) EnsureConnected() error { op := this.RetryPolicy.StartOperation() for { err := this.Impl.EnsureConnected() - if IsSuccessOrBenignError(err) || !op.ShouldRetry("Connect: %s", err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("Connect: %v", err) { return err } } @@ -41,7 +41,7 @@ func (this *FaultTolerantHdfsAccessor) OpenRead(path string) (ReadSeekCloser, er // wrapping returned HdfsReader with FaultTolerantHdfsReader return NewFaultTolerantHdfsReader(path, result, this.Impl, this.RetryPolicy), nil } - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] OpenRead: %s", path, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] OpenRead: %v", path, err) { return nil, err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -61,7 +61,7 @@ func (this *FaultTolerantHdfsAccessor) ReadDir(path string) ([]Attrs, error) { op := this.RetryPolicy.StartOperation() for { result, err := this.Impl.ReadDir(path) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] ReadDir: %s", path, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] ReadDir: %v", path, err) { return result, err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -75,7 +75,7 @@ func (this *FaultTolerantHdfsAccessor) Stat(path string) (Attrs, error) { op := this.RetryPolicy.StartOperation() for { result, err := this.Impl.Stat(path) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Stat: %s", path, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Stat: %v", path, err) { return result, err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -89,7 +89,7 @@ func (this *FaultTolerantHdfsAccessor) StatFs() (FsInfo, error) { op := this.RetryPolicy.StartOperation() for { result, err := this.Impl.StatFs() - if IsSuccessOrBenignError(err) || !op.ShouldRetry("StatFs: %s", err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("StatFs: %v", err) { return result, err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -103,7 +103,7 @@ func (this *FaultTolerantHdfsAccessor) Mkdir(path string, mode os.FileMode) erro op := this.RetryPolicy.StartOperation() for { err := this.Impl.Mkdir(path, mode) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Mkdir %s: %s", path, mode, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Mkdir %s: %v", path, mode, err) { return err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -117,7 +117,7 @@ func (this *FaultTolerantHdfsAccessor) Remove(path string) error { op := this.RetryPolicy.StartOperation() for { err := this.Impl.Remove(path) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Remove: %s", path, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Remove: %v", path, err) { return err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -131,7 +131,7 @@ func (this *FaultTolerantHdfsAccessor) Rename(oldPath string, newPath string) er op := this.RetryPolicy.StartOperation() for { err := this.Impl.Rename(oldPath, newPath) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Rename to %s: %s", oldPath, newPath, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("[%s] Rename to %s: %v", oldPath, newPath, err) { return err } else { // Clean up the bad connection, to let underline connection to get automatic refresh @@ -145,12 +145,11 @@ func (this *FaultTolerantHdfsAccessor) Chmod(path string, mode os.FileMode) erro op := this.RetryPolicy.StartOperation() for { err := this.Impl.Chmod(path, mode) - if IsSuccessOrBenignError(err) || !op.ShouldRetry("Chmod [%s] to [%d]: %s", path, mode, err) { + if IsSuccessOrBenignError(err) || !op.ShouldRetry("Chmod [%s] to [%d]: %v", path, mode, err) { return err - } else { - // Clean up the bad connection, to let underline connection to get automatic refresh - this.Impl.Close() } + // Clean up the bad connection, to let underline connection to get automatic refresh + this.Impl.Close() } } @@ -161,10 +160,9 @@ func (this *FaultTolerantHdfsAccessor) Chown(path string, user, group string) er err := this.Impl.Chown(path, user, group) if IsSuccessOrBenignError(err) || !op.ShouldRetry("Chown [%s] to [%s:%s]: %s", path, user, group, err) { return err - } else { - // Clean up the bad connection, to let underline connection to get automatic refresh - this.Impl.Close() } + // Clean up the bad connection, to let underline connection to get automatic refresh + this.Impl.Close() } }