network.request fails on app Update-Install claen is ok

claen==CLEAN—typo in heading apologies…

Hi

I have a piece of code that runs succesfully in Corona and in OSX simulators and on IOS  as well. Great!

BUT,  if I do an APP UPDATE ,[instead of remove and install] the code fails with file or directory not found.

Here is the code


local params = {}
    params.progress = “download”
    params.response = { filename = “temp.txt”,baseDirectory = system.TemporaryDirectory}
    network.request( _G.set.Url, “GET”, networkListener,  params )


If I delete the ‘temp folder’ in corona  simulator sandbox to try to simulate no directory it still works ok and the temp folder is created. If I uninstall from IOS and do a clean install with new version of app it still runs ok.

It is only if I update [in-place] the app fails. This situation is created by deleteing the app in iTunes, leaving the old app on iphone, add into iTunes the new app.The button caption changes to update, rather than install. I assume this simulates a real app update once published.

From the debug console


[My debug print]

Jun 11 12:42:16 Alecs-Laptops-iPhone ULTrA[600] <Warning>: PATH USED=    /private/var/mobile/Applications/EF15DFB3-559F-40CD-A82F-73827C910981/tmp/temp.txt
 

[IOS output]

Jun 11 12:42:16 Alecs-Laptops-iPhone ULTrA[600] <Warning>: Runtime error
    /Users/aleccockleNewMacbook/Library/Application Support/Outlaw/Sandbox/364/Trends/Results.lua:54: bad argument #1 to ‘lines’ (/private/var/mobile/Applications/EF15DFB3-559F-40CD-A82F-73827C910981/tmp/temp.txt: No such file or directory)
    stack traceback:


What other code do I need to test obscure condition of network request not creating in this situation? Ideas welcomed

Alec

Any one have any thoughts this. It still fails doing an update!

Thanks

I’m not sure what specifically is going on, but when you do a fresh install, you get empty system.TemporaryDirectory, system.CachesDirectory and system.DocumentsDirectory.  When you do an update, any files that already exist in those folders still exist.  I’ve had similar issues where I would be loading some settings but my settings file was corrupt and it created problems in my app.  A clean start of course solved the problem, but I immediately wrote out a bad settings file.

I would consider looking around to see what files you are trying to read and write and see if an existing file would cause you issues.

Rob

Thanks for the feedback and suggestions.

I have tried different directories  but still fails. I’ve narrowed it down to the actual network.request being the problem, because this function appears to create the temp.txt file in the app space. it does this as stated when new and ‘old’/existing or not,  But after the update it fails every time.

I am not sure how to investigate further. I have looked via Organser. at the application directory space and the files get created as described

Some how the update seems to get the network.request confused.

I had suspected maybe the path string was getting corrupted but that looks fine from the console.

It works ok in Corona and OSX simulator [how do you simulate an Update?].

What other download commands are available I could try instead of the async network.request?

Thanks

Why not try to download it to system.CachesDirectory and see if its an issue there.

Rob

Same issue…

I think I will go back and change the design a little to try a work-around. It is driving me crazy as it stands. I was thinking of actually testing and creating the tmp file before network.request gets to decide to create or not.  That way I know if it is there.  What does network.request expect with filename = “temp.txt”,baseDirectory = system.TemporaryDirectory and the file already exists…?


I thought it might be a profile issue, changed these too but still the same.


{as an aside I have also found a problem in Outlaw/ Corona simulator— If I change the code to point to different directories  and re-test,  the directory is not changed, but stays with the older string—to actaully change after changing code, I have to delete the project in outlaw and then add it back in—with the new code in deleted project— it then reloads and builds ok and goes to new coded directory-is this a clue or  red herring?}


I have been using tmp as a lazy option so I did not have to worry about deleting the file. Using system.CachesDirectory the same laziness stil applies I assume?

Any one have any thoughts this. It still fails doing an update!

Thanks

I’m not sure what specifically is going on, but when you do a fresh install, you get empty system.TemporaryDirectory, system.CachesDirectory and system.DocumentsDirectory.  When you do an update, any files that already exist in those folders still exist.  I’ve had similar issues where I would be loading some settings but my settings file was corrupt and it created problems in my app.  A clean start of course solved the problem, but I immediately wrote out a bad settings file.

I would consider looking around to see what files you are trying to read and write and see if an existing file would cause you issues.

Rob

Thanks for the feedback and suggestions.

I have tried different directories  but still fails. I’ve narrowed it down to the actual network.request being the problem, because this function appears to create the temp.txt file in the app space. it does this as stated when new and ‘old’/existing or not,  But after the update it fails every time.

I am not sure how to investigate further. I have looked via Organser. at the application directory space and the files get created as described

Some how the update seems to get the network.request confused.

I had suspected maybe the path string was getting corrupted but that looks fine from the console.

It works ok in Corona and OSX simulator [how do you simulate an Update?].

What other download commands are available I could try instead of the async network.request?

Thanks

Why not try to download it to system.CachesDirectory and see if its an issue there.

Rob

Same issue…

I think I will go back and change the design a little to try a work-around. It is driving me crazy as it stands. I was thinking of actually testing and creating the tmp file before network.request gets to decide to create or not.  That way I know if it is there.  What does network.request expect with filename = “temp.txt”,baseDirectory = system.TemporaryDirectory and the file already exists…?


I thought it might be a profile issue, changed these too but still the same.


{as an aside I have also found a problem in Outlaw/ Corona simulator— If I change the code to point to different directories  and re-test,  the directory is not changed, but stays with the older string—to actaully change after changing code, I have to delete the project in outlaw and then add it back in—with the new code in deleted project— it then reloads and builds ok and goes to new coded directory-is this a clue or  red herring?}


I have been using tmp as a lazy option so I did not have to worry about deleting the file. Using system.CachesDirectory the same laziness stil applies I assume?