]> Cypherpunks.ru repositories - nncp.git/commitdiff
DirSync after .seen creation
authorSergey Matveev <stargrave@stargrave.org>
Sat, 3 Jul 2021 17:08:46 +0000 (20:08 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 4 Jul 2021 17:11:24 +0000 (20:11 +0300)
src/toss.go

index f23b5836fe6374f53aefebdfdf6f95c5684519f4..6f91b43d799cf87100c96dc69deaf219cdd3aa8e 100644 (file)
@@ -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 {