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

freezing issue when SD card is full on wii u #118

Open
dwskcw opened this issue Apr 14, 2024 · 7 comments
Open

freezing issue when SD card is full on wii u #118

dwskcw opened this issue Apr 14, 2024 · 7 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dwskcw
Copy link

dwskcw commented Apr 14, 2024

platform: Wii U

it seems when attempting to update an app (specifically inkay) with a full sd card, store gets stuck on the downloading popup, beeps at full volume and is stuck in this state until force shutting down the console. does the app store check in any capacity for free space before downloading updates? sorry for the largely non technical description, i haven't filed a bug report before

@vgmoose
Copy link
Member

vgmoose commented Apr 14, 2024

Thanks for the bug report! It doesn't check indeed, and it probably should. This likely requires system specific APIs to check remaining free space prior to downloading/extracting.

This check should happen in libget around the Package:: downloadZip method, where it should return false if the Package's download_size + extracted_size (in KB) is greater than the remaining space, plus some padding.

I'm definitely interested in adding this kind of check and eventually reporting a good human-readable error message as well.

@vgmoose vgmoose added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 14, 2024
@chrisrq
Copy link

chrisrq commented Sep 13, 2024

Looking to contribute for the first time, is this still an issue and am I free to implement this if I'm able to? Thank you!

@vgmoose
Copy link
Member

vgmoose commented Sep 13, 2024

Absolutely!

@chrisrq
Copy link

chrisrq commented Sep 14, 2024

I should preface this by saying that I'm new to Nintendo homebrew development, so I apologize for any trouble I might cause while discussing proposed changes or if I ask any dumb questions. I wrote a draft for the relevant changes to be made to Package.cpp after checking if zipUrl is empty and before returning:

// check if there is enough free space to download this package
int space_needed = (this.getDownloadSize() + this.getExtractedSize()) / 1000;
int space_available = get_remaining_disk_space(tmp_path.data());
if (space_needed > space_available) {
	printf("--> ERROR: Space needed to  %s is %d KB, only %d KB of disk space remaining\n", this->pkg_name.c_str(), space_needed, space_available);
	return false;
}

get_remaining_disk_space() is a function I made a signature for in Util.hpp and am trying to work on a definition for in Util.cpp. I wasn't sure how to make this cleaner, but it would look something like this:

// returns remaining disk space
int get_remaining_disk_space(path) {
	#if defined(WIN32)
		// handle Win32 case
	#endif
	#if defined(SWITCH)
		// handle Nintendo Switch case
	#endif
	#if defined(_3DS)
		// handle Nintendo 3DS case
	#endif
	#if defined(_WII)
		// handle Wii case
	#endif
	// handle default case
}

I just needed to make sure my approach for how to handle the different cases is in the right direction (any feedback on the aforementioned functions is also appreciated). For the case of the 3DS, I read the libctru documentation and came up with this rough scheme of getting the remaining disk space:

- run fsInit()
- run fsMakePath() to get FS_Path from path specified in downloadZip (?)
- run FSUSER_OpenArchive() using the path from fsMakePath()
- run FSUSER_GetFreeBytes() using the path from OpenArchive()
- run fsExit() and FSUSER_CloseArchive()
- return result from GetFreeBytes() / 1000

Would this more or less be what we're trying to do? Am I missing some implications that this implementation might have or am I using the wrong functions? Any feedback is appreciated.

@vgmoose
Copy link
Member

vgmoose commented Sep 14, 2024

Yep, that looks like the right approach. I thought about mentioning those platform-specific variables in my last comment too. That's the current paradigm used throughout the codebase for platform-specific code. They are: SWITCH, __WIIU__, WII, _3DS, _WIN32, and __APPLE__ (reason for the underscore inconsistencies has to do with existing/common expectations)

In the default (aka unimplemented) case, a really large number (or a negative number, checked for positivity?) could be returned. And then piecewise the methods for each platform would be added to this method for calculating space remaining.

For the context of hb-appstore and its concerns, we only really need to check the total size remaining on the SD card, and not worry too much about the path of the downloaded/extracted content. Libget at this time only operates from wherever the SD card path is, which is defined in ROOT_PATH in Package.hpp. If there's other homebrew that is calculating SD card space remaining already, that would be good place to look to know how that can be implemented.

@chrisrq
Copy link

chrisrq commented Sep 15, 2024

Got it on the SD card part, I think I did see some libctru functions that would let me get the SD card path too which I can then use to open the relevant archive and get the remaining space using the other filesystem functions in fs.h, so I might be able to use that if I don't find something that does it all in one go.

And then piecewise the methods for each platform would be added to this method for calculating space remaining.

Just to clarify, do you mean I should format the get_remaining_disk_space() function the way I'm already doing it or a different way? Thank you for the help so far!

@vgmoose
Copy link
Member

vgmoose commented Sep 16, 2024

Yep, the way you have it with the ifdefs is good. What I meant by piecewise is just that we don't necessarily need to have every single platform solved at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants