FTP: Six Files Downloaded to Device From Server. One of the 6 Did Not Have Any Data.

Mahares

Expert
Licensed User
Longtime User
I use FTP ( Net Lib 1.31) to download 6 tab delimited text files from the server list to the tablet. The 6 files range from 1 KB to 200 KB in size. All made it to the tablet, but 1 file (1 KB) out of the 6 did not have any data when it reached the tablet, although it has data on the server. It happened only once so far. I could not reproduce it. Does anyone have any experience to help me see what might have happened?
Thank you very much
 

Mahares

Expert
Licensed User
Longtime User
All 6 files downloaded one after the other, except that one of them did not have any data in it. I use the following code:
B4X:
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
       Log(ServerPath & ", Success=" & Success)
       If Success = False Then 
            Msgbox("DOWNLOAD OF BASE FILES AND DAILY HISTORY FAILED. TIMED OUT. TRY AGAIN." & CRLF _
            & LastException.Message,"DOWNLOAD FAILED")
            Cursor1.Close              
                    SQL1.Close
'           Activity.Finish
           ExitApplication
         End If
   End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel: The user did not report anything out of the ordinary, as he got a message that all 6 files downloaded. I could not reproduce the problem. The fact that it downloaded a blank file, albeit empty, isn't that an indication that it was a success? Is there anything I should I add in the code to prevent something like this from happening in the future. For example, stop the download completely with a big message box, so the user notices it.
Thank you
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel:
1. Does success return false even when 5 of 6 text files download fine, or do I get false only for the one file that was empty. How can I achieve a success message box for each file individually as opposed to a quick toastmessage that flashes quickly and the user is not going to pay attention to, so I can determine which file did not download properly.
2. I know you are not a fan of ExitApplication, but it seemed to work better for me in this case as I was getting frequent:
An error has occurred in sub:main_activity_create (java line xxx).
Android.database.sqlite.SQLiteDatabase Locked Exception: database is locked (code5), while compiling: PRAGMA journal_mode.
when was using Activity.Finish.
3. What is your preferred way to upload and download text files to and from device as opposed to FTP without dealing with php. I have not had consistency using FTP.
Thank you again for being there for us.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. DownloadCompleted is called for each file. So it will return True for all the successful downloads and False for all the unsuccessful downloads. You should track the downloads and when all are complete show a message with the ones that failed.

2. Seems like a programming error. Is SQL a process global variable? Where is initialized?

3. It depends on your server. If it is a http server then you can use HttpUtils2.
 
Upvote 0
Top