Rename () sans fsync () est-il sûr?
Question
Est-il sûr d'appeler rename(tmppath, path)
sans appeler fsync(tmppath_fd)
première?
Je veux que le chemin pointe toujours vers un fichier complet. Je me soucie principalement de Ext4. Le renomment () est-il promis d'être en sécurité dans toutes les futures versions du noyau Linux?
Un exemple d'utilisation dans Python:
def store_atomically(path, data):
tmppath = path + ".tmp"
output = open(tmppath, "wb")
output.write(data)
output.flush()
os.fsync(output.fileno()) # The needed fsync().
output.close()
os.rename(tmppath, path)
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow