Skip to content

feat: add one resume action during modpack install if abort - #242

Open
HowXu wants to merge 28 commits into
FreesmTeam:developfrom
Nibelungorum:feat/206-abort-download-with-one-save-dialog
Open

HowXu wants to merge 28 commits into
FreesmTeam:developfrom
Nibelungorum:feat/206-abort-download-with-one-save-dialog

Conversation

@HowXu

@HowXu HowXu commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

from #206 , which discusses some features for the users who do not have a good networks or for the situation that network not work well

This PR adds resumable installation for Modrinth and CurseForge modpacks, helping users avoid downloading completed files again when their connection is unreliable. And one new global setting, disabled by default, lets users keep incomplete instances automatically without dialog. Choosing not to keep the instance preserves the existing cleanup behavior.

Large scope changes

This feature involves one large scope of adjustment in launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp and launcher/modplatform/flame/FlameInstanceCreationTask.cpp. I move the core download functions to the XXXInstallTask.cpp. I think if there is one class named XXXInstallTask, it should contains the code about download (but they are in the XXXInstanceCreationTask). Meanwhile, the download codes will be reused in the resume task.

If it's not suitable for the project, just tell me and I will do the modification

Test

Some simple tests

Manual testing of Modrinth and CurseForge installation and recovery was performed on Kali Linux, kernel 7.0.12, using Wayland with niri.

Keep

Unfortunately, this feature only implement for modrinth and curseforge modpack. other platforms are outside the scope of this PR. Platforms such as FTB, ATLauncher, and Technic use different manifests or installation workflows and require separate adaptations.

@so5iso4ka so5iso4ka added [1.1] : Freesm FreesmLauncher component [2.2] : Enhancement Improvement to existing functionality. [3.4] : Platform: Cross-Platform Tasks affecting all platforms. [4.1] : Component: Installation Related to managing Minecraft installations. [5.0] : User: End-Users Tasks aimed at end-users. labels Oct 24, 2026
@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch from d0a41ae to cc4cded Compare October 24, 2026 11:11
@so5iso4ka

Copy link
Copy Markdown
Member

Couldn't we achieve the same goal by keeping the current behavior and caching modpack content instead?

@s0me1newithhand7s

s0me1newithhand7s commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Couldn't we achieve the same goal by keeping the current behavior and caching modpack content instead?

+++
we wanna keep current behaviour

ed: stupid fucking idiot, absolute bafoon

@HowXu

HowXu commented Oct 24, 2026

Copy link
Copy Markdown
Author

Couldn't we achieve the same goal by keeping the current behavior and caching modpack content instead?

uhh, my bad English makes me do not completely understand your lines. The behavior of this pr is: I add one dialog when abort download or the download was aborted by bad networks, If choose "Yes" meaning keeping the content we have downloaded, then the modpack will be cached and one new instance was also created. If choose "No", the content was dropped, just behave like recent.

So does the line above meaning, uhh, like defaultly keeping the modpack cache and create one new instance ?

Just tell me more details

@notwindstone

notwindstone commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Couldn't we achieve the same goal by keeping the current behavior and caching modpack content instead?

uhh, my bad English makes me do not completely understand your lines. The behavior of this pr is: I add one dialog when abort download or the download was aborted by bad networks, If choose "Yes" meaning keeping the content we have downloaded, then the modpack will be cached and one new instance was also created. If choose "No", the content was dropped, just behave like recent.

So does the line above meaning, uhh, like defaultly keeping the modpack cache and create one new instance ?

Just tell me more details

He was saying that the solution to the problem might be more simple - just keep the downloaded modpack files in a shared cache folder. if something failed, the cached modpack files will be still present, and following retries will download only those files that are absent from cache

@notwindstone

Copy link
Copy Markdown
Member

Couldn't we achieve the same goal by keeping the current behavior and caching modpack content instead?

uhh, my bad English makes me do not completely understand your lines. The behavior of this pr is: I add one dialog when abort download or the download was aborted by bad networks, If choose "Yes" meaning keeping the content we have downloaded, then the modpack will be cached and one new instance was also created. If choose "No", the content was dropped, just behave like recent.

So does the line above meaning, uhh, like defaultly keeping the modpack cache and create one new instance ?

Just tell me more details

He was saying that the solution to the problem might be more simple - just keep the downloaded modpack files in a shared cache folder. if something failed, the cached modpack files will be still present, and following retries will download only those files that are absent from cache

probably need to clarify as well these things:

  • no need for the dialog - so yes, treat it as "by default, keep the downloaded files"
  • the proposed implementation keeps downloaded modpack files in the instance folder instead of the cache folder, independent of instance

@HowXu

HowXu commented Oct 24, 2026

Copy link
Copy Markdown
Author

Then I get.

Thanks a lot

@HowXu

HowXu commented Oct 24, 2026

Copy link
Copy Markdown
Author

some more details needs discuss below:

Where to keep the files already downloaded? Typically when install one mod pack, there will be modpack files(almost be downloaded from one single archive, and unzip, this will always keep stable), download mod files. The game sources download have already been cached.So what we care is the mod downloaded. In recent implement, I record one another manifest cut from the modpack mainfest, then the download will always be started if the files in the cut json do not be done. the downloaded mod files will directly send to the modpack instance's mods folder.

One more thing, if my understanding is right, after any abort of the modpack installation, there will always be one new instance?(so users can decide whether to delete) Or manage one another cache folder for the aborted instance? I do not suggest the second because we must control how to clean the cache, when to clean the cache and if the user restart the installation, we need check whether it's continuation or new installation, and even so more(but if it's better for the project, I will try my best).

@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch from 134a550 to 74906d1 Compare October 26, 2026 06:16
@so5iso4ka

Copy link
Copy Markdown
Member

Sorry for the delay!

Where to keep the files already downloaded?

This can be done using HttpMetaCache. In fact, it is already in use, but the cache is marked as stale before each modpack download starts.

One more thing, if my understanding is right, after any abort of the modpack installation, there will always be one new instance?

No, I'd like to keep the existing behavior, so if an error occurs or the user aborts the installation, no instance is created.

@HowXu

HowXu commented Nov 1, 2026

Copy link
Copy Markdown
Author

Sorry for the delay!

Where to keep the files already downloaded?

This can be done using HttpMetaCache. In fact, it is already in use, but the cache is marked as stale before each modpack download starts.

One more thing, if my understanding is right, after any abort of the modpack installation, there will always be one new instance?

No, I'd like to keep the existing behavior, so if an error occurs or the user aborts the installation, no instance is created.

get it

@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch 3 times, most recently from c4fb495 to ee368d5 Compare November 2, 2026 06:12
@HowXu

HowXu commented Nov 2, 2026

Copy link
Copy Markdown
Author

I've revised the behavior discussed above. Downloaded files are now cached through HttpMetaCache. The dialog was been removed.

This currently covers Modrinth and CurseForge. I plan to support the other platformsin follow-up changes.

There's one other point I'd like to discuss: HttpMetaCache doesn't appear to automatically reclaim disk space. If a user cancels a modpack installation and never retries it, the downloaded files could remain in the cache indefinitely. Would it make sense to periodically remove cached files that haven't been used for a long time? Since these files can be shared across modpacks, this would probably be better handled at the cache level rather than per modpack.

@fractal-l

Copy link
Copy Markdown
Contributor

yes. would be good to make this period as value option in settings

@HowXu

HowXu commented Nov 6, 2026

Copy link
Copy Markdown
Author

yes. would be good to make this period as value option in settings

@so5iso4ka I may not do this in this pr. I think it should be taken in consideration

@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch from db272de to cfdb4f8 Compare November 11, 2026 03:39
@HowXu

HowXu commented Nov 11, 2026

Copy link
Copy Markdown
Author

I've add all platform modpack download cache feature

ready for review @so5iso4ka

@HowXu
HowXu marked this pull request as ready for review November 11, 2026 03:43

@so5iso4ka so5iso4ka left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why implement such major changes when we could just add caching to the existing tasks?
For example, in ModrinthCreationTask this:

auto dl = Net::ApiDownload::makeFile(downloadUrl, filePath, Net::Download::Option::NoOptions, meta);
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));

could become something like:
(pseudocode)

auto entry = APPLICATION->metacache()->resolveEntry("general", "modpack-files/" + file.hash.toHex());
auto dl = Net::ApiDownload::makeCached(downloadUrl, entry, Net::Download::Option::MakeEternal, meta);
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));

// after
FS::copy(entry->getFullPath(), filePath)();

Or maybe better: something like MetaCacheSink, but with the target file name separated from the cache key, so it copies the cached file to the target path itself.

@HowXu

HowXu commented Nov 12, 2026 •

Copy link
Copy Markdown
Author

That's OK.

I would like to explain the changes first. In the first version I changed the instance creation process, and here:

This feature involves one large scope of adjustment in launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp and launcher/modplatform/flame/FlameInstanceCreationTask.cpp. I move the core download functions to the XXXInstallTask.cpp. I think if there is one class named XXXInstallTask, it should contains the code about download (but they are in the XXXInstanceCreationTask). Meanwhile, the download codes will be reused in the resume task.

If it's not suitable for the project, just tell me and I will do the modification

Meanwhile these repacked codes is convinient for me to do local unit tests. So there's such a big changes. That's my fault, feeling sorry.

Next version I will try to implement MetaCacheSink. It may take me some time.

@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch 3 times, most recently from 27bd897 to 292e4da Compare November 12, 2026 11:30
HowXu added 27 commits November 14, 2026 14:21
Distinguish network failures from local and parsing errors, clear stale replies on retries, and close canceled sinks before completion. Cover retry followed by local failure using real loopback networking.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Add the default-off automatic keep setting and shared creation handling. Preserve supported new instances after content interruption or game dependency network failure without changing Skip.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Share content installation between creation and resume, retain native pending entries, reuse validated files, and drain writes before a keep decision.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Resolve remaining native IDs, retain interrupted downloads, validate manual files and resource processing, and rollback uncommitted worlds safely.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Resume content before normal launch steps, reject explicit offline launches with pending content, and remove markers only after successful completion.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Keep successful requests without a valid landed file pending for fallback URLs, and verify SHA-512 before optional cleanup or manifest filtering.

Assisted-by: OpenCode:gpt-6.1-sol-fast
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
…fault action

Signed-off-by: HowXu <dev@howxu.cn>
Reuse HttpMetaCache for verified Modrinth and CurseForge content, copying cached files into staging while preserving optional files, fallback URLs and manual resource installation.

Remove incomplete-instance persistence and launch-time recovery. Keep the game-file Skip behavior and wait for content downloads to stop before staging cleanup. Add cache reuse and cancellation tests.

Assisted-by: Pi:gpt-6.1-sol
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Reuse HttpMetaCache for hashed ATLauncher mods and configs, FTB downloads and Technic Solder archives. Preserve existing download paths when usable hashes are unavailable and retain FTB's single-request limit.

Keep multiple ATLauncher installation targets for shared cache entries. Add focused platform-cache tests and remove stale registrations for previously deleted tests.

Assisted-by: Pi:gpt-6.1-sol
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
…eta cache

Signed-off-by: HowXu <dev@howxu.cn>
Assisted-by: Pi:gpt-6.1-sol
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Assisted-by: Pi:gpt-6.1-sol
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
Signed-off-by: HowXu <dev@howxu.cn>
@HowXu
HowXu force-pushed the feat/206-abort-download-with-one-save-dialog branch from 74330cf to a966505 Compare November 14, 2026 06:21
@HowXu

HowXu commented Nov 14, 2026

Copy link
Copy Markdown
Author

@so5iso4ka much better now. ready for review

Just tell me the lacks. I am a long time user of Freesm and I hope my code will improve it too

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[1.1] : Freesm FreesmLauncher component [2.2] : Enhancement Improvement to existing functionality. [3.4] : Platform: Cross-Platform Tasks affecting all platforms. [4.1] : Component: Installation Related to managing Minecraft installations. [5.0] : User: End-Users Tasks aimed at end-users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants