SMB file transfer not consistently work

blong

Active Member
Licensed User
Longtime User
I have been developing a program that uses the SMB Samba library to access a server box and download files. I need to download a complex directory tree to the SD card and it is tedious to say the least.

However I get random errors which may be network glitches or whatever when I request a file list like

mysmb.ListFiles(mydir,"")

when I check the ListCompleted event sometimes it is ok but other times the Success flag reports false. If is simply make my software "try again" i.e. issue the same request again it usually works fine.

I find programming for the SMB not straight forward as handling events for ListCompleted and DownloadCompleted requires complex logic when one has a complex and large number of files.

Anyone else experience this problem / bug ?

Am now coding up same logic using the MLFiles library and so far that seems much better.... will advise when finished.
 

blong

Active Member
Licensed User
Longtime User
Last exception

Added code to program and get LastException as follows

LE >> (SmbException) jcifs.smb.SmbException: smb://WL2-movies/PublicMovies/Catalogs/movies/What Women Want/
java.net.MalformedURLException: java.lang.StringIndexOutOfBoundsException

As I said in response before I simply attempt the list a second time and it works. Have had it loop 2 or 3 times before success.

I am downloading some 53 directories and program worked fine 4 times before failing at directory #19 ... it is never consistent.

Does the above exception mean the file string was corrupted ??
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
MLfiles

Erel

Have now got my program logic using the MLfiles Samba library rather than SMB.

It also gives random errors and the

FSerror flag gives the following message

java.lang.StringIndexOutOfBoundsException

so both libraries appear to have exactly same problem.

Assume it is a Java bug ??
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Good idea

Erel

Great suggestion (as always)...

BUT ... why does it seem to work say 90+% of the time.

As I said just resend the same request and 2nd time it works ??

What I don't like is the inconsistency ... the worst type of bug.
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Not work...

Erel

Tried adding %20 to strings as below

smb://WL2-movies/PublicMovies/Catalogs/MOVIES/A%20Common%20Man/

then I get consistent error

The system cannot find the path specified.

This is when using smblst=sf.SmbList(movie_path2,"")

and same again when using sf.SmbCopy(serverfile2,localfile2)

so problem must be more subtle ...

Back to my Try and Try again method... I guess.
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Wise to change

Erel

Would it be wise that I give up on filenames with spaces in them and directories with spaces in them ??

Replace with underscore character

A Few Good Men >>> A_Few_Good_Men

I NEVER get an error except when filename has spaces but still what I don't understand is why it works 90% of the time.

As I read the standard for an Android directory of file should be "no spaces"... correct ??
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Spaces vs underscore

Erel

Just tried renaming all directories which had spaces and all files with spaces to have underscores.

I still get random errors... almost seems like network had a minor glitch or ??

Usually a second attempt at the operation succeeds... rare to need more than a second attempt BUT can happen.

So all my hair now pulled out and ... :-(
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Files

Erel

I must admit that the errors "seem to" always occur in the longer files names.

As you may have noted the app I am building involves a media player and hence movie names. I have directories which are name of movie and under the directory files such as below

Directory > A_Few_Good_ Men

and files in that directory
> A_Few_Good_Men-poster.jpg
> A_Few_Good_Men-fanart.jpg
> A_Few_Good_Men.nfo

As stated in a couple of messages ago I changed all file names to NOT have spaces but rather underscore character as above.

The operation involves copying several directories (at the moment about 60 for testing... ultimately maybe 400) so lots of files. It randomly has problems on a directory, never the same ones, but consistently seems to be on LONGER files names as above rather than files/directories of a single word

eg Directory > Argo

and files Argo-poster.jpg etc

So again I ask... does Android REQUIRE no spaces in file names (though it seems to work 95% of the time).

My current software just retries up to 5 times to get operation done and usually it works on second attempt and rarely a third attempt needed.

But this seems like GLUDGE programming but gets the job done. NOTE that I am using MLfiles rather than SMB in all this testing now.

(Will be away for a few days ... so will not see reply until next week)
 
Upvote 0

blong

Active Member
Licensed User
Longtime User
Alternative ?

Erel

Thanks for comment ...

So do we presume a "bug" in the JCIFS.JAR file... I note from my web browsing that it has been not updated since 2011.

Is there an alternative ?

Should I maybe try FTP ?? or is it still using JCIFS ??
 
Upvote 0
Top