diff options
Diffstat (limited to 'backend/slackpkg.cc')
| -rw-r--r-- | backend/slackpkg.cc | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/backend/slackpkg.cc b/backend/slackpkg.cc index 74a7ecb..a750f2e 100644 --- a/backend/slackpkg.cc +++ b/backend/slackpkg.cc @@ -12,15 +12,14 @@ GHashTable *Slackpkg::cat_map = nullptr; /* * katja::Slackpkg::manifest: - * @job: a #PkBackendJob. + * @job: a #JobData. * @tmpl: temporary directory. * @filename: manifest filename * * Parse the manifest file and save the file list in the database. */ void -Slackpkg::manifest (PkBackendJob *job, - const char *tmpl, char *filename) noexcept +Slackpkg::manifest(JobData *job_data, const char *tmpl, char *filename) noexcept { FILE *manifest; int err, read_len; @@ -32,10 +31,9 @@ Slackpkg::manifest (PkBackendJob *job, GRegex *pkg_expr = nullptr, *file_expr = nullptr; GMatchInfo *match_info; sqlite3_stmt *statement = nullptr; - auto job_data = static_cast<JobData *> (pk_backend_job_get_user_data(job)); path = g_build_filename(tmpl, - this->get_name (), + this->get_name(), filename, nullptr); manifest = fopen(path, "rb"); @@ -169,19 +167,19 @@ Slackpkg::collect_cache_info (const char *tmpl) noexcept /* Create the temporary directory for the repository */ tmp_dir = g_file_new_for_path(tmpl); - repo_tmp_dir = g_file_get_child(tmp_dir, this->get_name ()); + repo_tmp_dir = g_file_get_child(tmp_dir, this->get_name()); g_file_make_directory(repo_tmp_dir, nullptr, nullptr); /* Download PACKAGES.TXT. These files are most important, break if some of them couldn't be found */ for (char **cur_priority = this->priority; *cur_priority; cur_priority++) { source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *))); - source_dest[0] = g_strconcat(this->get_mirror (), + source_dest[0] = g_strconcat(this->get_mirror(), *cur_priority, "/PACKAGES.TXT", nullptr); source_dest[1] = g_build_filename(tmpl, - this->get_name (), + this->get_name(), "PACKAGES.TXT", nullptr); source_dest[2] = nullptr; @@ -199,12 +197,12 @@ Slackpkg::collect_cache_info (const char *tmpl) noexcept /* Download file lists if available */ source_dest = static_cast<char **> (g_malloc_n(3, sizeof(char *))); - source_dest[0] = g_strconcat(this->get_mirror (), + source_dest[0] = g_strconcat(this->get_mirror(), *cur_priority, "/MANIFEST.bz2", nullptr); source_dest[1] = g_strconcat(tmpl, - "/", this->get_name (), + "/", this->get_name(), "/", *cur_priority, "-MANIFEST.bz2", nullptr); source_dest[2] = nullptr; @@ -239,7 +237,7 @@ out: * Returns: List of files needed for building the cache. **/ void -Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept +Slackpkg::generate_cache(JobData *job_data, const char *tmpl) noexcept { char **pkg_tokens = nullptr; char *query = nullptr, *filename = nullptr, *location = nullptr, *summary = nullptr, *line, *packages_txt; @@ -252,10 +250,7 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept sqlite3_stmt *insert_statement = nullptr, *update_statement = nullptr, *insert_default_statement = nullptr, *statement; /* Check if the temporary directory for this repository exists, then the file metadata have to be generated */ - packages_txt = g_build_filename(tmpl, - this->get_name (), - "PACKAGES.TXT", - nullptr); + packages_txt = g_build_filename(tmpl, this->get_name(), "PACKAGES.TXT", nullptr); list_file = g_file_new_for_path(packages_txt); fin = g_file_read(list_file, nullptr, nullptr); g_object_unref(list_file); @@ -271,11 +266,7 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept &statement, nullptr) == SQLITE_OK) { - sqlite3_bind_text(statement, - 1, - this->get_name (), - -1, - SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 1, this->get_name(), -1, SQLITE_TRANSIENT); sqlite3_step(statement); sqlite3_finalize(statement); } @@ -287,12 +278,8 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept { goto out; } - sqlite3_bind_int(statement, 1, this->get_order ()); - sqlite3_bind_text(statement, - 2, - this->get_name (), - -1, - SQLITE_TRANSIENT); + sqlite3_bind_int(statement, 1, this->get_order()); + sqlite3_bind_text(statement, 2, this->get_name(), -1, SQLITE_TRANSIENT); sqlite3_step(statement); sqlite3_finalize(statement); @@ -320,7 +307,7 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept "ext = @ext, location = @location, summary = @summary, " "desc = @desc, compressed = @compressed, uncompressed = @uncompressed " "WHERE name LIKE @name AND repo_order = %u", - this->get_order ()); + this->get_order()); if (sqlite3_prepare_v2(job_data->db, query, -1, &update_statement, nullptr) != SQLITE_OK) { goto out; @@ -392,7 +379,7 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept { statement = insert_default_statement; } - sqlite3_bind_int(statement, 11, this->get_order ()); + sqlite3_bind_int(statement, 11, this->get_order()); } else /* Update package information if it is a patch */ { @@ -433,7 +420,7 @@ Slackpkg::generate_cache (JobData *job_data, const char *tmpl) noexcept for (char **p = this->priority; *p; p++) { filename = g_strconcat(*p, "-MANIFEST.bz2", nullptr); - manifest (job, tmpl, filename); + manifest(job_data, tmpl, filename); g_free(filename); } out: |
