mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 05:05:56 +08:00
Using initial manifest file from resources.
The file itself is testing variant.
This commit is contained in:
parent
ed27ad0ca5
commit
118a1f6438
9
resources/profiles/ArchiveRepositoryManifest.json
Normal file
9
resources/profiles/ArchiveRepositoryManifest.json
Normal file
@ -0,0 +1,9 @@
|
||||
[{
|
||||
"name": "Production",
|
||||
"description": "Production repository",
|
||||
"visibility": "",
|
||||
"id": "prod",
|
||||
"url": "http://10.24.3.3:8001/v1/repos/prod/",
|
||||
"index_url": "http://10.24.3.3:8001/v1/repos/prod/vendor_indices.zip",
|
||||
"selected" : 1
|
||||
}]
|
@ -3163,14 +3163,6 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
|
||||
#endif // 0
|
||||
plater()->get_preset_archive_database()->set_wizard_lock(true);
|
||||
plater()->get_preset_archive_database()->sync_blocking();
|
||||
// Do blocking sync on every start of wizard, so user is always offered recent profiles.
|
||||
preset_updater->sync_blocking(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
|
||||
// Offer update installation (of already installed profiles) only when run by user.
|
||||
if (reason == ConfigWizard::RR_USER) {
|
||||
preset_updater->update_index_db();
|
||||
if (preset_updater->config_update(app_config->orig_version(), PresetUpdater::UpdateParams::FORCED_BEFORE_WIZARD) == PresetUpdater::R_ALL_CANCELED)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto wizard = new ConfigWizard(mainframe);
|
||||
const bool res = wizard->run(reason, start_page);
|
||||
@ -3875,16 +3867,6 @@ void GUI_App::show_printer_webview_tab()
|
||||
{
|
||||
mainframe->show_printer_webview_tab(preset_bundle->physical_printers.get_selected_printer_config());
|
||||
}
|
||||
/*
|
||||
void GUI_App::start_preset_updater(bool forced)
|
||||
{
|
||||
if (m_started_preset_updater && !forced) {
|
||||
return;
|
||||
}
|
||||
this->preset_updater->cancel_sync();
|
||||
this->preset_updater->sync(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
|
||||
m_started_preset_updater = true;
|
||||
}
|
||||
*/
|
||||
|
||||
} // GUI
|
||||
} //Slic3r
|
||||
|
@ -318,6 +318,7 @@ bool LocalArchiveRepository::get_archive(const fs::path& target_path) const
|
||||
PresetArchiveDatabase::PresetArchiveDatabase(AppConfig* app_config, wxEvtHandler* evt_handler)
|
||||
: p_evt_handler(evt_handler)
|
||||
{
|
||||
//
|
||||
boost::system::error_code ec;
|
||||
m_unq_tmp_path = fs::temp_directory_path() / fs::unique_path();
|
||||
fs::create_directories(m_unq_tmp_path, ec);
|
||||
@ -402,8 +403,11 @@ void PresetArchiveDatabase::remove_local_archive(const std::string& uuid)
|
||||
|
||||
void PresetArchiveDatabase::load_app_manifest_json()
|
||||
{
|
||||
std::string path = get_stored_manifest_path();
|
||||
std::ifstream file(path);
|
||||
const fs::path path = get_stored_manifest_path();
|
||||
if (!fs::exists(path)) {
|
||||
copy_initial_manifest();
|
||||
}
|
||||
std::ifstream file(path.string());
|
||||
std::string data;
|
||||
if (file.is_open()) {
|
||||
std::string line;
|
||||
@ -467,6 +471,23 @@ void PresetArchiveDatabase::load_app_manifest_json()
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to read archives JSON. " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
void PresetArchiveDatabase::copy_initial_manifest()
|
||||
{
|
||||
const fs::path target_path = get_stored_manifest_path();
|
||||
const fs::path source_path = fs::path(resources_dir()) / "profiles" / "ArchiveRepositoryManifest.json";
|
||||
assert(fs::exists(source_path));
|
||||
std::string error_message;
|
||||
CopyFileResult cfr = Slic3r::copy_file(source_path.string(), target_path.string(), error_message, false);
|
||||
assert(cfr == CopyFileResult::SUCCESS);
|
||||
if (cfr != CopyFileResult::SUCCESS) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to copy ArchiveRepositoryManifest.json from resources.";
|
||||
return;
|
||||
}
|
||||
static constexpr const auto perms = fs::owner_read | fs::owner_write | fs::group_read | fs::others_read;
|
||||
fs::permissions(target_path, perms);
|
||||
}
|
||||
|
||||
void PresetArchiveDatabase::save_app_manifest_json() const
|
||||
{
|
||||
/*
|
||||
@ -516,7 +537,7 @@ void PresetArchiveDatabase::save_app_manifest_json() const
|
||||
}
|
||||
data += "]";
|
||||
|
||||
std::string path = get_stored_manifest_path();
|
||||
std::string path = get_stored_manifest_path().string();
|
||||
std::ofstream file(path);
|
||||
if (file.is_open()) {
|
||||
file << data;
|
||||
@ -527,9 +548,9 @@ void PresetArchiveDatabase::save_app_manifest_json() const
|
||||
}
|
||||
}
|
||||
|
||||
std::string PresetArchiveDatabase::get_stored_manifest_path() const
|
||||
fs::path PresetArchiveDatabase::get_stored_manifest_path() const
|
||||
{
|
||||
return (boost::filesystem::path(Slic3r::data_dir()) / "ArchiveRepositoryManifest.json").make_preferred().string();
|
||||
return (boost::filesystem::path(Slic3r::data_dir()) / "ArchiveRepositoryManifest.json").make_preferred();
|
||||
}
|
||||
|
||||
bool PresetArchiveDatabase::is_selected(const std::string& uuid) const
|
||||
@ -655,15 +676,7 @@ bool sync_inner(const std::string& token, std::string& manifest)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
/*
|
||||
bool PresetArchiveDatabase::sync_blocking_with_token(const std::string& user_account_token)
|
||||
{
|
||||
bool ret_val = m_token != user_account_token && !user_account_token.empty();
|
||||
m_token = user_account_token;
|
||||
sync_blocking();
|
||||
return ret_val;
|
||||
}
|
||||
*/
|
||||
|
||||
void PresetArchiveDatabase::sync_blocking()
|
||||
{
|
||||
if (m_wizard_lock) {
|
||||
|
@ -102,9 +102,6 @@ public:
|
||||
~PresetArchiveDatabase() {}
|
||||
|
||||
const ArchiveRepositoryVector& get_archive_repositories() const { return m_archive_repositories; }
|
||||
// Sync does download manifest for online repos.
|
||||
// returns true if preset update should be forced - if access token has changed, there might be new repositories or it is a first call
|
||||
//bool sync_blocking_with_token(const std::string& user_account_token);
|
||||
void set_access_token(const std::string& token) { m_token = token; }
|
||||
void sync_blocking();
|
||||
//void set_local_archives(AppConfig* app_config);
|
||||
@ -118,10 +115,11 @@ public:
|
||||
void set_wizard_lock(bool lock);
|
||||
private:
|
||||
void load_app_manifest_json();
|
||||
void copy_initial_manifest();
|
||||
void save_app_manifest_json() const;
|
||||
void clear_online_repos();
|
||||
bool is_selected(const std::string& id) const;
|
||||
std::string get_stored_manifest_path() const;
|
||||
boost::filesystem::path get_stored_manifest_path() const;
|
||||
void consolidate_selected_uuids_map();
|
||||
std::string get_next_uuid();
|
||||
wxEvtHandler* p_evt_handler;
|
||||
|
Loading…
x
Reference in New Issue
Block a user