mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Replace file.flush() calls with flush_sync() helper
Calls to `os.fsync(f.fileno())` need to be accompained by `f.flush()`.
Commit 8bbeedc93f introduces the helper
`ipapython.ipautil.flush_sync()`, which handles all calls in the right
order.
However, `flush_sync()` takes as parameter a file object with fileno
and name, where name must be a path to the file, this isn't possible
in some cases where file descriptors are used.
Issue: https://pagure.io/freeipa/issue/7251
Signed-off-by: Armando Neto <abiagion@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
committed by
Christian Heimes
parent
f29412729e
commit
b274da726b
@@ -22,6 +22,7 @@ from ipalib.errors import SchemaUpToDate
|
||||
from ipalib.frontend import Object
|
||||
from ipalib.output import Output
|
||||
from ipalib.parameters import DefaultFrom, Flag, Password, Str
|
||||
from ipapython import ipautil
|
||||
from ipapython.ipautil import fsdecode
|
||||
from ipapython.dn import DN
|
||||
from ipapython.dnsutil import DNSName
|
||||
@@ -492,8 +493,7 @@ class Schema(object):
|
||||
dir=self._DIR, delete=False) as f:
|
||||
try:
|
||||
self._write_schema_data(f)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
ipautil.flush_sync(f)
|
||||
f.close()
|
||||
except Exception:
|
||||
os.unlink(f.name)
|
||||
|
||||
Reference in New Issue
Block a user