diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-04-15 09:56:09 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-04-15 09:56:09 +0300 |
commit | 9567337fd2444aa9b30a6cbfdd5bc9a98d171f25 (patch) | |
tree | 7811255a8e028774b154d67245283022092312b9 /src/database.c | |
parent | a23f6f4afb0f819c6c478975df41e235e8d0953a (diff) | |
download | apk-tools-9567337fd2444aa9b30a6cbfdd5bc9a98d171f25.tar.gz apk-tools-9567337fd2444aa9b30a6cbfdd5bc9a98d171f25.tar.bz2 apk-tools-9567337fd2444aa9b30a6cbfdd5bc9a98d171f25.tar.xz apk-tools-9567337fd2444aa9b30a6cbfdd5bc9a98d171f25.zip |
fetch: new applet to download .apk files
Fixes #24.
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/database.c b/src/database.c index 9bf34ba..7162ef7 100644 --- a/src/database.c +++ b/src/database.c @@ -693,18 +693,20 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) apk_blob_for_each_segment(blob, ":", add_protected_path, db); if (root != NULL) { - r = apk_db_read_state(db); - if (r == -ENOENT && (flags & APK_OPENF_CREATE)) { - r = apk_db_create(db); + if (!(flags & APK_OPENF_EMPTY_STATE)) { + r = apk_db_read_state(db); + if (r == -ENOENT && (flags & APK_OPENF_CREATE)) { + r = apk_db_create(db); + if (r != 0) { + msg = "Unable to create database"; + goto ret_r; + } + r = apk_db_read_state(db); + } if (r != 0) { - msg = "Unable to create database"; + msg = "Unable to read database state"; goto ret_r; } - r = apk_db_read_state(db); - } - if (r != 0) { - msg = "Unable to read database state"; - goto ret_r; } if (apk_repos == NULL) |