-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
Can one of the admins please verify this patch? |
0b4fbe1
to
be80f01
Compare
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. |
@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. |
Hooray Jenkins reported success with all tests good! |
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 🙂. |
Hooray Jenkins reported success with all tests good! |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.... 😐
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this 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")); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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...
Merged with minimal changes. |
@skaldarnar: Thanks! 😄 |
Belated "aw man sweet!" and reminder to please do this for the game itself sometime :D |
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 🙂