install: Call flush/fsync for critical pisi files

BUG:FIXED:13005
This commit is contained in:
Fatih Aşıcı
2010-05-24 11:32:41 +00:00
parent 32030e2301
commit 147513c537
2 changed files with 14 additions and 3 deletions
+3 -3
View File
@@ -502,17 +502,17 @@ class Install(AtomicOperation):
util.clean_dir(self.old_path)
ctx.ui.info(_('Storing %s') % ctx.const.files_xml, verbose=True)
self.package.extract_file(ctx.const.files_xml, self.package.pkg_dir())
self.package.extract_file_synced(ctx.const.files_xml, self.package.pkg_dir())
ctx.ui.info(_('Storing %s') % ctx.const.metadata_xml, verbose=True)
self.package.extract_file(ctx.const.metadata_xml, self.package.pkg_dir())
self.package.extract_file_synced(ctx.const.metadata_xml, self.package.pkg_dir())
for pcomar in self.metadata.package.providesComar:
fpath = os.path.join(ctx.const.comar_dir, pcomar.script)
# comar prefix is added to the pkg_dir while extracting comar
# script file. so we'll use pkg_dir as destination.
ctx.ui.info(_('Storing %s') % fpath, verbose=True)
self.package.extract_file(fpath, self.package.pkg_dir())
self.package.extract_file_synced(fpath, self.package.pkg_dir())
def update_databases(self):
"update databases"
+11
View File
@@ -79,6 +79,17 @@ class Package:
"""Extract file with path to outdir"""
self.extract_files([path], outdir)
def extract_file_synced(self, path, outdir):
"""Extract file with path to outdir"""
data = self.impl.read_file(path)
fpath = util.join_path(outdir, path)
util.check_dir(os.path.dirname(fpath))
with open(fpath, "wb") as f:
f.write(data)
f.flush()
os.fsync(f.fileno())
def extract_dir(self, dir, outdir):
"""Extract directory recursively, this function
copies the directory archiveroot/dir to outdir"""