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

functionality to update gpx traces from files #37

Merged
merged 6 commits into from
May 15, 2024

Conversation

jamescr
Copy link
Contributor

@jamescr jamescr commented May 10, 2024

implements Upload gpx from file #36

Copy link
Owner

@westnordost westnordost left a comment

Choose a reason for hiding this comment

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

Thanks, looks fine! I have a few comments on that.

(There is also a bug in the code, but it will go away after doing the requested changes.)

@jamescr
Copy link
Contributor Author

jamescr commented May 10, 2024

Thanks for the review, i applied the improvements to the code.

Comment on lines 223 to 226
InputStream is = new FileInputStream(gpxFile);

long id = privilegedApi.create("gpx file test case", Visibility.PRIVATE, "test case from gpx file desc",
tags, is);
Copy link
Owner

Choose a reason for hiding this comment

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

Oh, don't forget to close the file input stream after it is read, otherwise the file will stay open.

Also in your own OSMTracker code of course.

I read up whether it is good practice to close the input stream already in our case in TracesApi::create but the general opinion is that an input stream should be closed at the level where it is created. In any case, it might be a good hint to explicitly state that in the javadoc, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reminder to close the stream. Will add a line in the javadoc comment of the method.

@westnordost
Copy link
Owner

Great, thank you! There is one thing left that is also relevant for your implementation in OSMTracker. You'll likely want to use try-with-resources so that the file handle is always closed also if an IO exception occurs:

try (InputStream in = new FileInputStream(file)) {
  // ...
} catch (IOException e) {
  // ...
}

@westnordost
Copy link
Owner

Nice, thank you! Will release a new version today.

@westnordost westnordost merged commit 7f5c96d into westnordost:master May 15, 2024
@westnordost westnordost mentioned this pull request May 15, 2024
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.

2 participants