dcsimg
Results 1 to 4 of 4

Thread: File Failure

  1. #1

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,752

    File Failure

    I'm using Cordova to make an Android tablet app. This may not be quite the forum for such a question, but the language is JavaScript, and I'm not quite sure where the real question lies.

    The application uses the Cordova file plugin:

    https://cordova.apache.org/docs/en/l...a-plugin-file/

    which allows access to the file system. This application has now worked fine on half a dozen, or so, tablets of two different brands. However, on one tablet, I am getting some really peculiar behavior.

    The code first gets a directory, then for the directory it does this:

    Code:
     dir.getFile(fileName, { create: true }, function (fileEntry) {},writeFailure)
    I left out the body of the success function. Basically, the call is to get a file from a directory. The fileName is the name of the file to get, then there's an argument to create it if it doesn't exist, a method to call on success, and writeFailure is a method to call on failure.

    The problem is that BOTH functions are being called. The user sees the message from writeFailure, but I also confirmed that the program is calling the success method, and is actually doing what it should, which is saving the file.

    I would assume that a method that takes both a success and failure callback, should call one or the other, but never both. In a way, I could sort of work around this by not having the error callback show a message. The user would just see the code working, but that defeats the whole purpose of an error callback, as the user wouldn't know about a legitimate failure. Also, for this design, I can't alert the user that the file saved...at least not all that well.

    So, I'm at a bit of a loss. I can't see into the getFile method, which probably isn't JS to begin with (it's probably either C++ or, more likely, Java). I don't see any reason why both success and failure would result from a method call, or ever SHOULD result from a method call.

    Any insight would be welcome.
    My usual boring signature: Nothing

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,137

    Re: File Failure

    What version is the file plugin?

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,786

    Re: File Failure

    Do you need a RETURN 0 or RETURN 1 or RETURN TRUE or something like that in your function body to "expose" success to the plugin so that it does not call the failure function?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,752

    Re: File Failure

    I used two different versions, but I'm currently still seeing the problem with the most recent version.

    @szlamany: The method works as is on several devices, and is just failing on the one, so I don't believe I need anything more. Naturally, I'm leaning towards the idea that something is corrupted on that one device, I'm just looking for any other possibilities.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width