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

Fix #677 Error if project is in OneDrive #680

Merged
merged 14 commits into from
Nov 3, 2023

Conversation

spacey-sooty
Copy link
Contributor

@spacey-sooty spacey-sooty commented Oct 18, 2023

Should Resolve #677

@@ -56,6 +56,9 @@ interface Parameters extends FlowParameters {
@Override
public void execute(Parameters parameters) {
Optional<Throwable> failure = parameters.getBuildResult().get().getFailure();
if (System.getProperty("user.dir").contains("OneDrive")) {
Copy link
Member

Choose a reason for hiding this comment

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

We want to be checking the project directory, not the user directory. Because this would still error even if you move the project.

Copy link
Member

Choose a reason for hiding this comment

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

Also, we'd want to do a case insensitive comparison.

Copy link
Member

Choose a reason for hiding this comment

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

Both of these comments still need to be fixed.

@spacey-sooty spacey-sooty marked this pull request as ready for review October 18, 2023 05:45
@@ -56,6 +59,10 @@ interface Parameters extends FlowParameters {
@Override
public void execute(Parameters parameters) {
Optional<Throwable> failure = parameters.getBuildResult().get().getFailure();
if (Paths.get("").toAbsolutePath().toString().toUpperCase().contains("ONEDRIVE")) {
Copy link
Member

Choose a reason for hiding this comment

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

This is also not correct. There are gradle methods on Settings to get the location of the whole project. Those are what should be used.

@@ -77,6 +78,9 @@ public void execute(Parameters parameters) {

@Override
public void apply(Project project) {
if (project.getRootDir().toString().toUpperCase().contains("ONEDRIVE")) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm still a bit worried about if this causes an issue when working in other languages. Wrap the contains portion in its own try catch that just catches and ignores any exception. But make sure the thrown OneDriveException isn't contained in that try catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only place I could see it getting ignored is in checkBuildFailed. We might want to add a clause when checking for exceptions about this

Copy link
Member

Choose a reason for hiding this comment

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

Apply is called at the very beginning. This is the right place to put it.

Copy link
Member

Choose a reason for hiding this comment

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

If it’s not clear, I’m worried about toUpperCase throwing a weird exception in other languages. So if we try catch any exception potentially thrown by that whole statement, we cover our bases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cant find anywhere else where the error would be ignored so should be good

Copy link
Contributor Author

@spacey-sooty spacey-sooty Oct 31, 2023

Choose a reason for hiding this comment

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

Ohh ok so it should be wrapped in a try catch

Copy link
Member

Choose a reason for hiding this comment

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

Just the whole statement doing the comparison. You would need to throw the onedrive exception outside of that try catch so it’s not accidentally caught.

Copy link
Member

@ThadHouse ThadHouse Oct 31, 2023

Choose a reason for hiding this comment

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

No. That is not what I want. Just the contains statement should be in the try catch. The throw statement needs to still be outside the try catch. With a bool used to tell if it should be thrown or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right ok i'll fix that in my last commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok should be fixed now

onedrive = true;
}
} catch(Exception e) {
System.out.println(e.toString());
Copy link
Member

Choose a reason for hiding this comment

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

Don't print anything here. We just want to ignore any issue completely.

@@ -77,6 +78,18 @@ public void execute(Parameters parameters) {

@Override
public void apply(Project project) {
boolean onedrive = false;
try {
if (project.getRootDir().toString().toUpperCase().contains("ONEDRIVE")) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need the if here. You can just assign onedrive straight to the whole result of the contains statement.

System.out.println(e.toString());
}

if (onedrive == true) {
Copy link
Member

Choose a reason for hiding this comment

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

Just if (onedrive) {, don't need the == true.

_project = project;
}

public void printError() {
Copy link
Member

Choose a reason for hiding this comment

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

Don't need the printError function, or to store the project variable.

@ThadHouse ThadHouse merged commit e05c24f into wpilibsuite:main Nov 3, 2023
@spacey-sooty spacey-sooty deleted the onedrive-fix branch July 8, 2024 01:28
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

Successfully merging this pull request may close these issues.

Error out early if building on OneDrive
2 participants