/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2023 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
"time"
)
+var NoSync bool
+
+func init() {
+ NoSync = os.Getenv(CfgNoSync) != ""
+}
+
func TempFile(dir, prefix string) (*os.File, error) {
// Assume that probability of suffix collision is negligible
suffix := strconv.FormatInt(time.Now().UnixNano()+int64(os.Getpid()), 16)
}
func DirSync(dirPath string) error {
+ if NoSync {
+ return nil
+ }
fd, err := os.Open(dirPath)
if err != nil {
return err
tmp.Fd.Close()
return err
}
- if err = tmp.Fd.Sync(); err != nil {
- tmp.Fd.Close()
- return err
+ if !NoSync {
+ if err = tmp.Fd.Sync(); err != nil {
+ tmp.Fd.Close()
+ return err
+ }
}
if err = tmp.Fd.Close(); err != nil {
return err