Commit a96572fb authored by Timo Teräs's avatar Timo Teräs
Browse files

db: compressed index file

parent f0609951
......@@ -21,7 +21,6 @@ typedef int (*apk_archive_entry_parser)(void *ctx,
struct apk_istream *istream);
int apk_file_get_info(const char *filename, struct apk_file_info *fi);
struct apk_istream *apk_gunzip_bstream(struct apk_bstream *);
int apk_parse_tar(struct apk_istream *, apk_archive_entry_parser parser, void *ctx);
int apk_parse_tar_gz(struct apk_bstream *, apk_archive_entry_parser parser, void *ctx);
......@@ -38,6 +38,8 @@ struct apk_bstream {
void (*close)(void *stream, csum_p csum);
struct apk_istream *apk_gunzip_bstream(struct apk_bstream *);
struct apk_istream *apk_istream_from_fd(int fd);
struct apk_istream *apk_istream_from_file(const char *file);
size_t apk_istream_skip(struct apk_istream *istream, size_t size);
......@@ -46,6 +48,8 @@ size_t apk_istream_splice(void *stream, int fd, size_t size);
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream);
struct apk_bstream *apk_bstream_from_fd(int fd);
struct apk_istream *apk_istream_from_file_gz(const char *file);
apk_blob_t apk_blob_from_istream(struct apk_istream *istream, size_t size);
apk_blob_t apk_blob_from_file(const char *file);
......@@ -670,8 +670,8 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
.url = apk_blob_cstr(repository)
snprintf(tmp, sizeof(tmp), "%s/APK_INDEX", db->repos[r].url);
is = apk_istream_from_file(tmp);
snprintf(tmp, sizeof(tmp), "%s/APK_INDEX.gz", db->repos[r].url);
is = apk_istream_from_file_gz(tmp);
if (is == NULL) {
apk_error("Failed to open index file %s", tmp);
return -1;
......@@ -362,3 +362,15 @@ int apk_file_get_info(const char *filename, struct apk_file_info *fi)
return 0;
struct apk_istream *apk_istream_from_file_gz(const char *file)
int fd;
fd = open(file, O_RDONLY);
if (fd < 0)
return NULL;
return apk_gunzip_bstream(apk_bstream_from_fd(fd));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment