Apache Cordova
  1. Apache Cordova
  2. CB-2171

FileTransfer.download leaves 0 byte file in filesystem on 404 from server

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.4.0
    • Component/s: Android
    • Labels:
      None
    • Environment:

      Android 2.3.

      Description

      To reproduce:

      Call fileTransfer.download, passing a URL which returns 404.

      Error callback will be correctly fired. But 0-byte file will be left on filesystem. This is because:

      FileOutputStream outputStream = new FileOutputStream(file);

      is called before the getInputStream is called.

        Activity

        Hide
        Joe Bowser added a comment -

        Pull requests are welcome!

        Show
        Joe Bowser added a comment - Pull requests are welcome!
        Hide
        Clayton Grassick added a comment -

        outputStream = new FileOutputStream(file);

        should happen after

        inputStream = getInputStream(connection);

        to prevent the issue, not before.

        Show
        Clayton Grassick added a comment - outputStream = new FileOutputStream(file); should happen after inputStream = getInputStream(connection); to prevent the issue, not before.
        Show
        Joe Bowser added a comment - https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commit;h=7ace1d652d665c850941531c18cdc55b9c7981b3

          People

          • Assignee:
            Joe Bowser
            Reporter:
            Clayton Grassick
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development