Hi All,
I've been implementing data backup for my app and have some strange results. Has anyone seen this behaviour before?
I create a folder using File.MakeDir and try to copy a file into it. I then get the following exception :
Further examination revealed that the folder is created and the permissions look correct (using ES File Explorer), but somehow this folder is not writeable. I can't copy a file into it at all, either in my app, or ES File Explorer. The folder is somehow corrupt.
So... I implemented the following bit of code :
The results of running this repeatedly are basically after a random number of retries
I've been implementing data backup for my app and have some strange results. Has anyone seen this behaviour before?
I create a folder using File.MakeDir and try to copy a file into it. I then get the following exception :
B4X:
(Exception) java.lang.Exception: java.io.FileNotFoundException: /storage/emulated/0/Android/data/gtl.stockmate/files/out5/hh_auth.txt: open failed: ENOENT (No such file or directory)
Further examination revealed that the folder is created and the permissions look correct (using ES File Explorer), but somehow this folder is not writeable. I can't copy a file into it at all, either in my app, or ES File Explorer. The folder is somehow corrupt.
So... I implemented the following bit of code :
B4X:
Dim created As Boolean
Dim retries As Int
retries = 0
created = False
Do While Not (created)
Try
File.MakeDir(Main.Home_Folder, "out" & outid)
File.Copy(Main.Home_Folder, "hh_auth.txt", Main.Home_Folder & "/out" & outid, "hh_auth.txt")
created = True
Catch
Log(LastException)
retries = retries + 1
created = False
If File.Exists(Main.Home_Folder, "out" & outid) Then
File.Delete(Main.Home_Folder, "out" & outid)
End If
End Try
Loop
If retries > 0 Then
Msgbox("Retries - " & retries, "Error")
End If
The results of running this repeatedly are basically after a random number of retries
(16,14,8,0,0,19,10,5,0,20 in a run of ten tests), the folder is successfully created and the file copied in.
This only seems to happen when creating a folder which previously existed (it get's deleted earlier in the backup process). The retries above are for a folder which previously contained 10 files.
I re-tested using a folder which contained 70 files and had the following number of retries -
133,246,171,244,276,159,246,251,232,232
This is hinting that it's related to file allocation tables, but I know very little about filesystems so....
Has anyone had a similar issue, and can suggest what's might be going on and/or workarounds smarter then retrying lots of times?
Thanks!!
This only seems to happen when creating a folder which previously existed (it get's deleted earlier in the backup process). The retries above are for a folder which previously contained 10 files.
I re-tested using a folder which contained 70 files and had the following number of retries -
133,246,171,244,276,159,246,251,232,232
This is hinting that it's related to file allocation tables, but I know very little about filesystems so....
Has anyone had a similar issue, and can suggest what's might be going on and/or workarounds smarter then retrying lots of times?
Thanks!!