Permalink
Browse files

correctly flush and fsync files written to flash memory

  • Loading branch information...
1 parent bddca82 commit cb963698fbf38ee129c0e451571025c2f24793ba @amonzner amonzner committed Sep 27, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 bonjour/src/Bonjour.py
View
@@ -3,7 +3,7 @@
from xml.etree.cElementTree import parse as cet_parse
from xml.etree.ElementTree import ParseError
from os import path, listdir
-from os import remove as os_remove
+from os import remove as os_remove, fsync
class Bonjour:
AVAHI_SERVICES_DIR = '/etc/avahi/services/'
@@ -60,6 +60,8 @@ def __writeService(self, service):
try:
file = open(filepath, 'w');
file.writelines(self.__createServiceConfig(service))
+ file.flush()
+ fsync(file.fileno())
file.close()
return True
except IOError:

0 comments on commit cb96369

Please sign in to comment.