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

Added check for insufficient space #392

Closed
wants to merge 3 commits into from

Conversation

iojw
Copy link
Member

@iojw iojw commented Dec 18, 2016

Addresses #390

The launcher now checks if there's sufficient space in the download directory before downloading the zip from Jenkins. It also sends a warning message that space is running low if the available space is less than twice the size of the zip file.

As for the warning sign, I haven't added it in first as I'm not sure what would be the best approach:

I was thinking about the download icon turning yellow whenever the space is low, but that would involve setting the style using code so I'm not very sure if it's ok. Or would it be better if something like this appeared in the lower left corner as a sign? For the threshold, I'm thinking about maybe when the available space goes below 200MB?

Let me know what you think 🙂

@GooeyHub
Copy link
Member

Can one of the admins please verify this patch?

@iojw iojw force-pushed the insufficient_space branch from 0b4fbe1 to be80f01 Compare December 18, 2016 14:39
@iojw
Copy link
Member Author

iojw commented Dec 18, 2016

Took a look into #386 as well and seems it's just a simple issue of the launcher not updating. I should have fixed it by adding the update calls.

@Cervator
Copy link
Member

@GooeyHub: add to whitelist

@iojw: thanks! @skaldarnar mentioned he'd be able to look at this tomorrow. Feel free to poke at other stuff until then :-)

I personally like the idea of the warning icon appearing somewhere, then if you click it (or hover over?) it could give you some details of the warning.

Maybe an ideal approach would be adding a tooltip summary of the warning as you hover over the warning icon, and if applicable clicking the icon would open some relevant UI element.

Over in engine land with MovingBlocks/Terasology#1402 there is a feature request for something similar, but much bigger, on trying to better indicate in the game UI when warnings or errors have been issued in the log. The launcher has the nice log tab right in the UI. Could be neat to have something similar in the game, with a line per "warning" of some sort, and the icon could open that screen.

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

@iojw
Copy link
Member Author

iojw commented Dec 19, 2016

Cool! based on @Cervator's comments, I managed to come up with this:

Clicking on it takes you to the Log tab, where you can see a logged warning regarding the low space. Also removed the warning dialog that appears when you click the Download button since the warning sign already accomplishes the same role. I was thinking that this could also be extended to other types of warnings as well in the future.

This is my first time with JavaFX so let me know if there's anything wrong with the FXML and all that. If it's alright, I'll still need to add the image source to the credits page 🙂.

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

Copy link
Member

@rzats rzats left a comment

Choose a reason for hiding this comment

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

Looks good to me - appreciate the misc. fixes in different files 🙂 The icon should probably be made grayscale to fit with the general look of the launcher.

@@ -501,6 +512,15 @@ private void updateButtons() {
downloadButton.setVisible(true);
cancelDownloadButton.setVisible(false);
}

// if less than 200MB available
if (downloadDirectory.getUsableSpace() <= 200 * 1000000) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be 1048576? (1024 * 1024)

Copy link
Member Author

@iojw iojw Dec 19, 2016

Choose a reason for hiding this comment

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

I tried to do a bit of research and this seems to be quite a contentious issue. There seem to be 2 units (1 megabyte = 1000 bytes, 1 mebibyte = 1024 bytes) and different platforms seem to use different units (Windows uses mebibytes, Mac uses megabytes). No idea which one would better.... 😐

Copy link
Member

Choose a reason for hiding this comment

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

in any case, we should get rid of the magic numbers (I don't mind the small error induced by mega vs mebibyte). Maybe use something like
private static final int MINIMAL_FREE_SPACE_IN_MB = 200 * 1000 * 1000

Copy link
Member

Choose a reason for hiding this comment

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

You can use something like

private static final long MB = 1024L * 1024;
private static final long MINIMUM_FREE_SPACE_IN_MB = 200 * MB;

or just the MB if that's the only location where it is used. If it happens to be used more often, we could aim for a ByteUnit enum containing these constants...

Copy link
Member

@skaldarnar skaldarnar left a comment

Choose a reason for hiding this comment

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

Your changes look good! I'll merge it real quick and apply the little changes myself 😉
I like the color icon as it brings the attention down there, and it fits with the social media buttons in the bottom...

if (downloadDirectory.getUsableSpace() <= 200 * 1000000) {
warningButton.setVisible(true);
warningButton.setTooltip(new Tooltip(BundleUtils.getLabel("message_warning_lowOnSpace")));
logger.warn(BundleUtils.getLabel("message_warning_lowOnSpace"));
Copy link
Member

Choose a reason for hiding this comment

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

The logged warning should contain some more info on how much space is actually left on disk, or how much free space is required to successfully perform the action.

@@ -501,6 +512,15 @@ private void updateButtons() {
downloadButton.setVisible(true);
cancelDownloadButton.setVisible(false);
}

// if less than 200MB available
if (downloadDirectory.getUsableSpace() <= 200 * 1000000) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use something like

private static final long MB = 1024L * 1024;
private static final long MINIMUM_FREE_SPACE_IN_MB = 200 * MB;

or just the MB if that's the only location where it is used. If it happens to be used more often, we could aim for a ByteUnit enum containing these constants...

@skaldarnar
Copy link
Member

Merged with minimal changes.

@skaldarnar skaldarnar closed this Dec 19, 2016
@iojw
Copy link
Member Author

iojw commented Dec 20, 2016

@skaldarnar: Thanks! 😄

@skaldarnar skaldarnar added Type: Enhancement New features or noticable improvements. Topic: UI Related to user interface (UI) or design. labels Dec 21, 2016
@skaldarnar skaldarnar added this to the v3.1.1 milestone Dec 21, 2016
@Cervator
Copy link
Member

Belated "aw man sweet!" and reminder to please do this for the game itself sometime :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic: UI Related to user interface (UI) or design. Type: Enhancement New features or noticable improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants