Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reinstating check_updates #88

Open
CajunAvenger opened this issue Sep 18, 2024 · 5 comments
Open

reinstating check_updates #88

CajunAvenger opened this issue Sep 18, 2024 · 5 comments

Comments

@CajunAvenger
Copy link
Collaborator

I'd like to set up a new host for Check online for updates, but I'm not sure how to format the data I'm sending to MSE. From reading update_checker.cpp and related, it looks like it should be approximately the form

updates:
	version: 2.5.0
	description: HTML description of update
	new updates url: https://host.com/updates
	packages:
		magic-m15:
			package: magic-m15
			version: 2024-09-18
installers:
	magic-m15:
		description:
			name: M15 Basic Style
		installer:
			installer_url: https://host.com/Magic - M15 Style.mse-installer
			installer_file: Magic - M15 Style.mse-installer

i've tried send this as this raw text, this text unindented, in JSON form, and each of those as the content of a file named "updates", and none of those was the trick.

MSE is getting the server response, but here in update_checker isn't reading data MSE understands, so it just closes the update thinking there's no updates.

      Reader reader(*isP, nullptr, _("updates"), true);
      reader.handle(version_data);
@CajunAvenger
Copy link
Collaborator Author

have gotten a lil further

version 2.5.2
description: Test

is showing up, but i haven't got it to recognize there's an mse-install yet

@haganbmj
Copy link
Owner

Lemme poke around, I think all that package logic is 15+ years old and appears to have been never really fully finished seeing as it wasn't added to all the stuff in the data directory pre-fork.

The entire section titled "Installing" was commented out.
https://github.com/haganbmj/MagicSetEditor2/blob/master/src/data/installer.cpp#L55-L159

and has been for 16 years? When it was though it seems like it was while Upgrading and Installing were being combined... so maybe it was just unnecessary stuff.

eed8ba4#diff-e646c89d75506ba3db2acc1b2d9228fb376c14ac3ec840f39151821ac3ef0126R41

@haganbmj
Copy link
Owner

This seems to be the only place that new updates url gets used.

static void Work() {
if (checking_updates) return; // don't check multiple times simultaniously
checking_updates = true;
try {
#if !USE_OLD_STYLE_UPDATE_CHECKER
String& the_url = settings.package_versions_url;
#else
String& the_url = settings.updates_url;
#endif
wxURL url(the_url);
unique_ptr<wxInputStream> isP(url.GetInputStream());
if (!isP) return; // failed to get data
// Read version data
// ignore errors for forwards compatability
VersionDataP version_data;
Reader reader(*isP, nullptr, _("updates"), true);
reader.handle(version_data);
// has the updates url changed?
if (!version_data->new_updates_url.empty()) {
the_url = version_data->new_updates_url;
}
// Make available
update_version_data = version_data;
} catch (...) {
// ignore all errors, we don't want problems if update checking fails
}
checking_updates = false;
}
};

And it's confusing to me since that's after the default update url is applied, and looks like it would never happen?

I also saw this block here that seems to be for representing the status on that update list, but it isn't an else block so it reads as if it would only ever work for fresh installs and not updates. So not sure if I'm reading the wrong spot for that too.

void InstallablePackage::determineStatus() {
status = PACKAGE_NOT_INSTALLED;
if (installer) {
status = (PackageStatus)(status | PACKAGE_INSTALLER);
if (!installed || installed->version <= description->version) {
status = (PackageStatus)(status | PACKAGE_INSTALLABLE);
}
if (!installed || installed->version < description->version) {
status = (PackageStatus)(status | PACKAGE_NOT_UP_TO_DATE);
}
}
if (installed) {
status = (PackageStatus)(status | PACKAGE_INSTALLED);
if (!(installed->status & PackageVersion::STATUS_FIXED)) {
status = (PackageStatus)(status | PACKAGE_REMOVABLE);
}
#if USE_MODIFIED_CHECK
if (installed->status & PackageVersion::STATUS_MODIFIED) {
status = (PackageStatus)(status | PACKAGE_MODIFIED);
}
#endif
}
}

@CajunAvenger
Copy link
Collaborator Author

CajunAvenger commented Sep 26, 2024

sorry i should have linked better

right here is where MSE reads the data it gets from the server

wxURL url(the_url);
unique_ptr<wxInputStream> isP(url.GetInputStream());
if (!isP) return; // failed to get data
// Read version data
// ignore errors for forwards compatability
VersionDataP version_data;
Reader reader(*isP, nullptr, _("updates"), true);
reader.handle(version_data);

the VersionData class is defined here, which gets Version, Description, and New Update URL, which I have been able to get the program to recognize

class VersionData : public IntrusivePtrBase<VersionData> {
public:
Version version; ///< Latest version number of MSE
String description; ///< html description of the latest MSE release
String new_updates_url; ///< updates url has moved?
DECLARE_REFLECTION();
};

the description gets used here

html->SetPage(update_version_data->description);

but i can't figure out how to get it to read the packages list from the server response, so it can actually download the installers. the best idea i've gotten so far is maybe it should be happening here, but we're on USE_OLD_STYLE_UPDATE_CHECKER and this is getting skipped with no alternative being available?

bool update_available() {
if (!update_version_data) return false;
#if !USE_OLD_STYLE_UPDATE_CHECKER
// updates to any installed package?
FOR_EACH_CONST(p, update_version_data->packages) {
if (!settings.check_updates_all && p->package != mse_package) continue;
Version v;
if (package_manager.installedVersion(p->package, v) && v < p->version) {
return true;
}
}
return false;
#else
return update_version_data->version > app_version;
#endif
}

@haganbmj
Copy link
Owner

Yeah if I'm reading the history of this right it looks like the original update pattern was that all the packages were distributed "officially" and the updater only worked for one endpoint that kind of maintained all of them. I can try removing that "USE_OLD" check and just see what happens. I want to look around and see what else that applies to; the hardcoded update urls are all to the old SourceForge page which is broken anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants