Skip to content

Commit

Permalink
auto-update index only when database is opened for writing
Browse files Browse the repository at this point in the history
  • Loading branch information
fabled committed Jan 8, 2018
1 parent d0a25d6 commit 5f7dcad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/apk_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ struct apk_database {
unsigned int pending_triggers;
int performing_self_upgrade : 1;
int permanent : 1;
int open_write : 1;
int open_complete : 1;
int compat_newfeatures : 1;
int compat_notinstallable : 1;
Expand Down
3 changes: 2 additions & 1 deletion src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
r = -1;
goto ret_r;
}
if (dbopts->open_flags & APK_OPENF_WRITE) db->open_write = 1;
if (!dbopts->cache_dir) dbopts->cache_dir = "etc/apk/cache";

apk_db_setup_repositories(db, dbopts->cache_dir);
Expand Down Expand Up @@ -2263,7 +2264,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
r = apk_repo_format_real_url(db, repo, NULL, buf, sizeof(buf));
if (r == 0) apk_message("fetch %s", buf);
} else {
apk_repository_update(db, repo);
if (db->open_write) apk_repository_update(db, repo);
r = apk_repo_format_cache_index(APK_BLOB_BUF(buf), repo);
}
} else {
Expand Down

0 comments on commit 5f7dcad

Please sign in to comment.