am e908a454: am 042c3cd0: Force sync files written by minzip.

* commit 'e908a45420fc4194c6007193d21d5b690e04583f':
  Force sync files written by minzip.
This commit is contained in:
Michael Runge
2014-10-31 00:13:21 +00:00
committed by Android Git Automerger
+8 -2
View File
@@ -1067,7 +1067,8 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
setfscreatecon(secontext); setfscreatecon(secontext);
} }
int fd = creat(targetFile, UNZIP_FILEMODE); int fd = open(targetFile, O_CREAT|O_WRONLY|O_TRUNC|O_SYNC
, UNZIP_FILEMODE);
if (secontext) { if (secontext) {
freecon(secontext); freecon(secontext);
@@ -1082,7 +1083,12 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
} }
bool ok = mzExtractZipEntryToFile(pArchive, pEntry, fd); bool ok = mzExtractZipEntryToFile(pArchive, pEntry, fd);
close(fd); if (ok) {
ok = (fsync(fd) == 0);
}
if (close(fd) != 0) {
ok = false;
}
if (!ok) { if (!ok) {
LOGE("Error extracting \"%s\"\n", targetFile); LOGE("Error extracting \"%s\"\n", targetFile);
ok = false; ok = false;