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

issue-16: fix download bug in data product delivery #18

Conversation

IslaL
Copy link
Contributor

@IslaL IslaL commented Apr 11, 2024

Obtain and save data from response to avoid accessing the website again.

@IslaL IslaL added the bug Something isn't working label Apr 11, 2024
@IslaL IslaL self-assigned this Apr 11, 2024
@@ -96,41 +98,44 @@
if length(lengthData) == 1
this.fileSize = str2double(lengthData.Value);
else
this.fileSize = strlength(response.Body.Data);
ext = util.extractFileExtension(filename);
if strcmp(ext, 'xml')
Copy link

@KristenMeyerONC KristenMeyerONC Apr 18, 2024

Choose a reason for hiding this comment

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

You can remove a level of nesting here by:

                    ext = util.extractFileExtension(filename);
                    if length(lengthData) == 1
                        this.fileSize = str2double(lengthData.Value);
                    elseif strcmp(ext, 'xml')
                        this.fileSize = length(xmlwrite(response.Body.Data));
                    else
                        this.fileSize = strlength(response.Body.Data);
                    end

Choose a reason for hiding this comment

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

Well that did not format well, one sec

@@ -0,0 +1,13 @@
function ext = extractFileExtension(filename)

Choose a reason for hiding this comment

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

Instead of this function you can use: https://www.mathworks.com/help/matlab/ref/fileparts.html which also handles string and char array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this function is a perfect fit! I will update the codes

@IslaL
Copy link
Contributor Author

IslaL commented Apr 18, 2024

The auto test shows that test Test09_ArchiveFiles/testDirectDownloadValidParamsMultiplePages failed when testing on Windows. It happened occasionally when i run the test locally, but it always fixed itself without any modifications. I just ran this test locally and it passed. I'm not sure if this has something to do with the server.

Error occurred in Test09_ArchiveFiles/testDirectDownloadValidParamsMultiplePages and it did not run to completion.
      ---------
      Error ID:
      ---------
      'MATLAB:dimagree'
      --------------
      Error Details:
      --------------
      Error using matlab.net.http.RequestMessage/sendOneRequest
      Matrix dimensions must agree.
      
      Error in matlab.net.http.RequestMessage/sendAfterChallenge (line 1674)
                      [response, request, history] = obj.sendOneRequest(connector, options, ...
      
      Error in matlab.net.http.RequestMessage/sendAndAuthenticate (line 1133)
                                         obj.sendAfterChallenge(response, connector, ...
      
      Error in matlab.net.http.RequestMessage/send (line 543)
                                   obj.sendAndAuthenticate([], completedURI, [], connector, options, ...
      
      Error in util.do_request (line 28)
          response = request.send(uri,options);
      
      Error in onc.OncArchive/getFile (line 65)
                      util.do_request(url, filters, 'timeout', this.timeout, 'showInfo', this.showInfo, ...
      
      Error in onc.OncArchive/getDirectFiles (line 161)
                          downInfo = this.getFile(filename, overwrite, 'showMsg', false);
      
      Error in Test09_ArchiveFiles/testDirectDownloadValidParamsMultiplePages (line 178)
                  result = this.onc.getDirectFiles(this.paramsLocationMultiPages);
      
      Caused by:
          Error using /
          Matrix dimensions must agree.

@IslaL
Copy link
Contributor Author

IslaL commented Apr 18, 2024

Just re-ran the windows auto test and it passed.

@IslaL IslaL merged commit cd76c88 into release-staging-24.03 Apr 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants