Back to issue from pre-refactor!
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name 2025-05-18 20:23:15 +12:00
parent fb6974b51a
commit d80820db15

View File

@ -90,7 +90,7 @@ namespace dropshell
ASSERT(ctx.args.size() == 3, "Invalid number of arguments");
std::string server = ctx.args[0];
std::string service = ctx.args[1];
std::string backup_file = ctx.args[2];
std::string backup_arg = ctx.args[2];
server_env_manager server_env(server);
if (!server_env.is_valid())
@ -106,7 +106,7 @@ namespace dropshell
}
std::optional<shared_commands::cBackupFileName> backup_details;
if (backup_file == "latest")
if (backup_arg == "latest")
{ // special case.
std::vector<shared_commands::cBackupFileName> backups = get_backup_files(server, service, service_info.template_name); // this service only (and also match template in case something changed there!).
if (backups.empty())
@ -117,15 +117,15 @@ namespace dropshell
}
backup_details = backups[0];
} else {
backup_details = shared_commands::cBackupFileName(backup_file);
}
bool backup_details_okay = backup_details.has_value() && backup_details->is_valid();
if (!backup_details_okay)
backup_details = shared_commands::cBackupFileName(backup_arg);
if (!backup_details->is_valid())
{
error << "Invalid backup file: " << backup_file << std::endl;
error << "Invalid backup file: " << backup_arg << std::endl;
return 1;
}
}
ASSERT(backup_details.has_value() && backup_details->is_valid(), "Invalid backup file.");
std::string local_backups_dir = gConfig().get_local_backup_path();
if (local_backups_dir.empty() || !std::filesystem::exists(local_backups_dir))
@ -133,7 +133,7 @@ namespace dropshell
error << "Error: Local backups directory not found: " << local_backups_dir << std::endl;
return 1;
}
std::string local_backup_file_path = (std::filesystem::path(local_backups_dir) / backup_file).string();
std::string local_backup_file_path = (std::filesystem::path(local_backups_dir) / backup_details->get_filename()).string();
if (!std::filesystem::exists(local_backup_file_path))
{
error << "Error: Backup file not found at " << local_backup_file_path << std::endl;
@ -177,7 +177,7 @@ namespace dropshell
{ // restore service from backup
info << "3) Restoring service data from backup..." << std::endl;
std::string remote_backups_dir = remotepath::backups(server);
std::string remote_backup_file_path = remote_backups_dir + "/" + backup_file;
std::string remote_backup_file_path = remote_backups_dir + "/" + backup_details->get_filename();
// Copy backup file from local to server
if (!shared_commands::scp_file_to_remote(server_env, local_backup_file_path, remote_backup_file_path, false))