From d647ff64b0d63df265ab903ff01fc3dc61ee6ee5 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 3 Jul 2021 20:08:46 +0300 Subject: [PATCH] DirSync after .seen creation --- src/toss.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/src/toss.go b/src/toss.go index f23b583..6f91b43 100644 --- a/src/toss.go +++ b/src/toss.go @@ -199,7 +199,18 @@ func jobProcess( if !dryRun && jobPath != "" { if doSeen { if fd, err := os.Create(jobPath + SeenSuffix); err == nil { - fd.Close() // #nosec G104 + fd.Close() + if err = DirSync(filepath.Base(jobPath)); err != nil { + ctx.LogE("rx-dirsync", les, err, func(les LEs) string { + return fmt.Sprintf( + "Tossing file %s/%s (%s): %s: dirsyncing", + sender.Name, pktName, + humanize.IBytes(pktSize), + filepath.Base(jobPath), + ) + }) + return err + } } } if err = os.Remove(jobPath); err != nil { @@ -381,7 +392,18 @@ func jobProcess( if jobPath != "" { if doSeen { if fd, err := os.Create(jobPath + SeenSuffix); err == nil { - fd.Close() // #nosec G104 + fd.Close() + if err = DirSync(filepath.Base(jobPath)); err != nil { + ctx.LogE("rx-dirsync", les, err, func(les LEs) string { + return fmt.Sprintf( + "Tossing file %s/%s (%s): %s: dirsyncing", + sender.Name, pktName, + humanize.IBytes(pktSize), + filepath.Base(jobPath), + ) + }) + return err + } } } if err = os.Remove(jobPath); err != nil { @@ -495,7 +517,18 @@ func jobProcess( if jobPath != "" { if doSeen { if fd, err := os.Create(jobPath + SeenSuffix); err == nil { - fd.Close() // #nosec G104 + fd.Close() + if err = DirSync(filepath.Base(jobPath)); err != nil { + ctx.LogE("rx-dirsync", les, err, func(les LEs) string { + return fmt.Sprintf( + "Tossing file %s/%s (%s): %s: dirsyncing", + sender.Name, pktName, + humanize.IBytes(pktSize), + filepath.Base(jobPath), + ) + }) + return err + } } } if err = os.Remove(jobPath); err != nil { @@ -573,7 +606,18 @@ func jobProcess( if !dryRun && jobPath != "" { if doSeen { if fd, err := os.Create(jobPath + SeenSuffix); err == nil { - fd.Close() // #nosec G104 + fd.Close() + if err = DirSync(filepath.Base(jobPath)); err != nil { + ctx.LogE("rx-dirsync", les, err, func(les LEs) string { + return fmt.Sprintf( + "Tossing file %s/%s (%s): %s: dirsyncing", + sender.Name, pktName, + humanize.IBytes(pktSize), + filepath.Base(jobPath), + ) + }) + return err + } } } if err = os.Remove(jobPath); err != nil { -- 2.44.0