From: Sergey Matveev Date: Sat, 3 Jul 2021 17:08:46 +0000 (+0300) Subject: DirSync after .seen creation X-Git-Tag: v7.1.0^2~3 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=d647ff64b0d63df265ab903ff01fc3dc61ee6ee5;p=nncp.git DirSync after .seen creation --- 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 {