Fixed issue where assets would not installed due to directory not being created

This commit is contained in:
David Allen 2022-07-30 09:34:21 -05:00
parent 2fd55de71e
commit 060d19bda4
10 changed files with 193 additions and 137 deletions

View file

@ -1,4 +1,5 @@
#include "constants.hpp"
#include <sqlite3.h>
#include <vector>
#include <string>
@ -9,16 +10,16 @@ namespace gdpm::package_manager{
namespace gdpm::cache{
using namespace package_manager;
int create_package_database();
int insert_package_info(const std::vector<package_info>& package);
std::vector<package_info> get_package_info_by_id(const std::vector<size_t>& package_ids);
std::vector<package_info> get_package_info_by_title(const std::vector<std::string>& package_titles);
std::vector<package_info> get_installed_packages();
int update_package_info(const std::vector<package_info>& packages);
int update_sync_info(const std::vector<std::string>& download_urls);
int delete_packages(const std::vector<std::string>& package_titles);
int delete_packages(const std::vector<size_t>& package_ids);
int drop_package_database();
int create_package_database(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int insert_package_info(const std::vector<package_info>& package, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_package_info_by_id(const std::vector<size_t>& package_ids, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_package_info_by_title(const std::vector<std::string>& package_titles, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_installed_packages(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int update_package_info(const std::vector<package_info>& packages, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int update_sync_info(const std::vector<std::string>& download_urls, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int delete_packages(const std::vector<std::string>& package_titles, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_TABLENAME);
int delete_packages(const std::vector<size_t>& package_ids, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int drop_package_database(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::string to_values(const package_info& package);
std::string to_values(const std::vector<package_info>& packages);

View file

@ -5,6 +5,7 @@
#include <string>
#include <filesystem>
#include <vector>
#include <set>
namespace gdpm::config{
@ -16,7 +17,7 @@ namespace gdpm::config{
std::string godot_version;
std::string packages_dir;
std::string tmp_dir;
std::vector<std::string> remote_sources;
std::set<std::string> remote_sources;
size_t threads;
size_t timeout;
bool enable_sync;
@ -26,7 +27,7 @@ namespace gdpm::config{
std::string to_json(const config_context& params);
config_context load(std::filesystem::path path, int verbose = 0);
int save(const config_context& config, int verbose = 0);
config_context make_config(const std::string& username = GDPM_CONFIG_USERNAME, const std::string& password = GDPM_CONFIG_PASSWORD, const std::string& path = GDPM_CONFIG_PATH, const std::string& token = GDPM_CONFIG_TOKEN, const std::string& godot_version = GDPM_CONFIG_GODOT_VERSION, const std::string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const std::string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const std::vector<std::string>& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
config_context make_config(const std::string& username = GDPM_CONFIG_USERNAME, const std::string& password = GDPM_CONFIG_PASSWORD, const std::string& path = GDPM_CONFIG_PATH, const std::string& token = GDPM_CONFIG_TOKEN, const std::string& godot_version = GDPM_CONFIG_GODOT_VERSION, const std::string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const std::string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const std::set<std::string>& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
extern config_context config;
}

View file

@ -13,7 +13,7 @@ namespace gdpm::constants{
constexpr const char *TmpPath = "$HOME/.config/gdpm/tmp";
}
/* Defines to set when building with -DGPM_* */
/* Define default macros to set when building with -DGPM_* */
#define GDPM_CONFIG_USERNAME ""
#define GDPM_CONFIG_PASSWORD ""
#define GDPM_CONFIG_PATH "config.json"
@ -28,13 +28,13 @@ namespace gdpm::constants{
#define GDPM_CONFIG_ENABLE_FILE_LOGGING 0
#define GDPM_CONFIG_VERBOSE 0
/* Defines package cache for local storage */
/* Defines the default package cache for local storage */
#define GDPM_PACKAGE_CACHE_ENABLE 1
#define GDPM_PACKAGE_CACHE_PATH "tests/gdpm/packages.db"
#define GDPM_PACKAGE_CACHE_TABLENAME "cache"
#define GDPM_PACKAGE_CACHE_COLNAMES "asset_id, type, title, author, author_id, version, godot_version, cost, description, modify_date, support_level, category, remote_source, download_url, download_hash, is_installed, install_path"
/* Defines to set default assets API params */
/* Define macros to set default assets API params */
#define GDPM_DEFAULT_ASSET_TYPE any
#define GDPM_DEFAULT_ASSET_CATEGORY 0
#define GDPM_DEFAULT_ASSET_SUPPORT all

14
include/version.hpp Normal file
View file

@ -0,0 +1,14 @@
#pragma once
#include <string>
namespace gdpm::version{
struct version_context{
int major;
int minor;
int patch;
};
std::string to_string(const version_context& context);
version_context to_version(const std::string& version);
}