Skip to content

Commit 37b264c

Browse files
committed
More gracefully handle offline downgrade
1 parent 35eca0a commit 37b264c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

gpt4all-updater/src/CommandFactory.cxx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@ std::shared_ptr<Command> CommandFactory::GetCommand(CommandType type)
1414
#ifdef OFFLINE
1515
// If we're offline, we're only installing or removing
1616
gpt4all::state::Gpt4AllState::getInstance().driveOffline();
17+
// This command always removes the current install
18+
// only return a command if updating
19+
if (type == CommandType::UPDATE)
20+
{
21+
active_command = std::make_shared<gpt4all::updater::Update>(gpt4all::state::Gpt4AllState::getInstance().getInstaller());
22+
}
23+
else {
24+
active_command = std::shared_ptr<gpt4all::command::Command>(nullptr);
25+
}
1726
#else
1827
if (type == CommandType::UPDATE || type == CommandType::DOWNGRADE) {
1928
gpt4all::download::Download::instance()->driveFetchAndInstall();
2029
}
2130
else {
2231
if(!gpt4all::state::Gpt4AllState::getInstance().getExistingInstaller()){
2332
qWarning() << "Unable to execute requested command, requires existing installation of gpt4all";
33+
QCoreApplication.exit(1);
2434
}
2535
}
26-
#endif
2736
QFile &installer = gpt4all::state::Gpt4AllState::getInstance().getInstaller();
2837
switch(type){
2938
case CommandType::UPDATE:
@@ -35,5 +44,6 @@ std::shared_ptr<Command> CommandFactory::GetCommand(CommandType type)
3544
case CommandType::UNINSTALL:
3645
active_command = std::make_shared<gpt4all::uninstall::Uninstall>(installer);
3746
}
47+
#endif
3848
return active_command;
3949
}

gpt4all-updater/src/main.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int main(int argc, char ** argv)
1414
CommandFactory cmd;
1515
gpt4all::command::CommandType command_type(cli.command());
1616
std::shared_ptr<gpt4all::command::Command> installer_command = cmd.GetCommand(command_type);
17-
installer_command->execute();
17+
if(installer_command)
18+
installer_command->execute();
1819
return 0;
1920
}

0 commit comments

Comments
 (0)