[pacman-dev] [PATCH] Sync data after writing to the local db

Allan McRae allan at archlinux.org
Sat Oct 30 02:59:58 EDT 2010


This should hopefully reduce local db corruption issues.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/be_local.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 4574bd4..cb12abb 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -841,6 +841,7 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
 			fprintf(fp, "\n");
 		}
 
+		fdatasync(fileno(fp));
 		fclose(fp);
 		fp = NULL;
 	}
@@ -869,6 +870,8 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
 			}
 			fprintf(fp, "\n");
 		}
+
+		fdatasync(fileno(fp));
 		fclose(fp);
 		fp = NULL;
 	}
-- 
1.7.3.2



More information about the pacman-dev mailing list