Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-22 20:14:49 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-22 20:14:49 +0000
commit8179f7cbaa62d4dccf85683b78206d9751d513d7 (patch)
treed438461b9c396d06e1d4f9abb34fb37dc2664d28 /lib/libalpm/db.c
parent621e241279c37f00775f5e06f15f6928b969cdc7 (diff)
- added db_setlastupdate to db.c
- moved db_update from db.c to alpm.c
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c62
1 files changed, 14 insertions, 48 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 68a83b0d..f98706b9 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -103,17 +103,17 @@ int db_create(char *root, char *dbpath, char *treename)
* Returns 0 on success, 1 on error
*
*/
-int db_getlastupdate(pmdb_t *db, char *root, char *dbpath, char *ts)
+int db_getlastupdate(pmdb_t *db, char *ts)
{
FILE *fp;
char path[PATH_MAX];
- if(db == NULL) {
+ if(db == NULL || ts == NULL) {
return(-1);
}
/* get the last update time, if it's there */
- snprintf(path, PATH_MAX, "%s%s/%s/.lastupdate", root, dbpath, db->treename);
+ snprintf(path, PATH_MAX, "%s/.lastupdate", db->path);
if((fp = fopen(path, "r")) == NULL) {
return(-1);
} else {
@@ -130,60 +130,26 @@ int db_getlastupdate(pmdb_t *db, char *root, char *dbpath, char *ts)
return(0);
}
-int db_update(pmdb_t *db, char *root, char *dbpath, char *archive, char *ts)
+/* writes the dbpath/.lastupdate with the contents of *ts
+ */
+int db_setlastupdate(pmdb_t *db, char *ts)
{
- char path[PATH_MAX];
-
- if(db == NULL) {
- return(-1);
- }
-
- snprintf(path, PATH_MAX, "%s%s/%s", root, dbpath, db->treename);
-
- /* ORE
- if(ts && strlen(ts)) {
- Should we refuse to update the db if it is already uptodate?
- if(ts != db_getlastupdate(db)) {
- RET_ERR(PM_ERR_DB_UPTODATE, -1);
- }
- }*/
-
- /* remove the old dir */
- /* ORE - do we want to include alpm.h and use the log mechanism from db.c?
- _alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", path);*/
- /* ORE
- We should only rmrf the database content, and not the top directory, in case
- a (DIR *) structure is associated with it (i.e a call to db_open). */
- _alpm_rmrf(path);
+ FILE *fp;
+ char file[PATH_MAX];
- /* make the new dir */
- if(db_create(root, dbpath, db->treename) != 0) {
+ if(db == NULL || ts == NULL || strlen(ts) == 0) {
return(-1);
}
- /* uncompress the sync database */
- /* ORE
- _alpm_log(PM_LOG_FLOW2, "Unpacking %s...\n", archive);*/
- if(_alpm_unpack(archive, path, NULL)) {
+ snprintf(file, PATH_MAX, "%s/.lastupdate", db->path);
+ if((fp = fopen(file, "w")) == NULL) {
return(-1);
}
-
- /* writes the db->path/.lastupdate with the contents of *ts */
- if(ts && strlen(ts)) {
- FILE *fp;
- char file[PATH_MAX];
-
- snprintf(file, PATH_MAX, "%s/.lastupdate", path);
- if((fp = fopen(file, "w")) == NULL) {
- return(-1);
- }
- if(fputs(ts, fp) <= 0) {
- fclose(fp);
- return(-1);
- }
+ if(fputs(ts, fp) <= 0) {
fclose(fp);
+ return(-1);
}
-
+ fclose(fp);
return(0);
}