Morning,
I need to improve the reliability for one of my mobile Apps (iOS) to edit and maintain a shared register of sorts (actually is just a text filed housed on a FTP Server, only have access to FTP Server)
In terms of reliability speed etc is it better to:
A : Download a copy of the register, place into a Variable and write changes then REPLACE the register with the edited Variable? (please note this is what I am doing now and occasionally if the PUT fails it places an empty file on the Server but I get no error returned ??)
B : Write the changes/additions directly to the server file (this way if it fails it won't empty the file??)
Note - The Application has to be able to store these changes if offline and action them again once it has a connection.
In this situation there will be around 10-20 users reading and modifying this register on a daily basis so if you were doing this what sort of methodology would you apply?
Am I doing this in a generally acceptable way?
Best Methodology...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Best Methodology...
Hi Nakia,
I'd go with A, but that's just me.
This might not work for you if the file is very large.
Oh, </endtag> would have to be filtered out on the client side.
Simon
I'd go with A, but that's just me.
Here I'd add a tag at the end of the file e.g. </endtag> and read the file right after posting it checking to make sure that the file ended in </endtag>. If it doesn't... "repeat as needed". The loop is easy.(please note this is what I am doing now and occasionally if the PUT fails it places an empty file on the Server but I get no error returned ??)
This might not work for you if the file is very large.
Oh, </endtag> would have to be filtered out on the client side.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Best Methodology...
Thanks Simon..
Let me pose this scenario however.
User 1 performs some changes to the register and upon the replace it fails after the 3 attempts and places an empty file on the server (Not in connection area).. The user closes the app.. (the updates go into the queue of things to be updated when the APP is opened next)
User 2 tries to make some changes to the register after User 1 did above but the register is empty....
Any suggestions on how I can avoid this scenario...
Let me pose this scenario however.
User 1 performs some changes to the register and upon the replace it fails after the 3 attempts and places an empty file on the server (Not in connection area).. The user closes the app.. (the updates go into the queue of things to be updated when the APP is opened next)
User 2 tries to make some changes to the register after User 1 did above but the register is empty....
Any suggestions on how I can avoid this scenario...
Re: Best Methodology...
I think that is called a database.
With the </endtag> User 1 knows the file did not upload so there is other actions to be taken (send email, "Try again?", etc.).
I do have a type of solution but before I go into details (to avoid being ridiculed by people in the know
), let me throw out an idea and maybe you'll figure out the rest.
For the filename of the download use sequential numbering e.g. 001_myData.txt. When finished editing upload a filename incremented by 1 e.g. 002_myData.txt.
OK I'll leave it like that. You can ask me to finish my thoughts, but for now I'll be wearing suspenders and a belt.
Simon
With the </endtag> User 1 knows the file did not upload so there is other actions to be taken (send email, "Try again?", etc.).
I do have a type of solution but before I go into details (to avoid being ridiculed by people in the know

For the filename of the download use sequential numbering e.g. 001_myData.txt. When finished editing upload a filename incremented by 1 e.g. 002_myData.txt.
OK I'll leave it like that. You can ask me to finish my thoughts, but for now I'll be wearing suspenders and a belt.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Best Methodology...
Thanks Simon,
I am aware that a Database would be the best Solution but I am not at that stage yet, also SQL Lite is not recomended for client server architecture (according to the webiste)
I did actually consider your "hinted" suggestion in a slightly different fashion. When the App uploads the edited file it will have the .new file extention, if that does not error on the upload the
handler then deletes the old file and changes the file name extention of the edited file..
I would be interested to hear the remainder of your suggestion if you wouldn't mind...
I am aware that a Database would be the best Solution but I am not at that stage yet, also SQL Lite is not recomended for client server architecture (according to the webiste)
I did actually consider your "hinted" suggestion in a slightly different fashion. When the App uploads the edited file it will have the .new file extention, if that does not error on the upload the
handler then deletes the old file and changes the file name extention of the edited file..
I would be interested to hear the remainder of your suggestion if you wouldn't mind...
Re: Best Methodology...
OK, but only because you asked.
I'll start by saying there is a troubled mode to my idea. User 1 and User 2 download and edit the file at the same time... Now if you can live with a sad workaround to that read on...
Oh, before you stop reading, mySQL is the one you want for online multi-user.
User 1 downloads 001_data.txt edits it and uploads 002_data.txt
User 2 ftp "LIST"'s the folders content and figures out the highest number (002_data.txt) downloads that, edit, uploads 003_data.txt.
Now everybody is going through User 2 process until the trouble starts and this is the 3rd action. ftp "LIST" before the upload and determine if there is a file by that name already. Here is where the problem is. How to merge the 2 new files?
Well you could download the file and just append the new txt to the doc I guess. Show them the new file with the append and ask if they wish to continue. (Kind of like what they do here if someone has replied to a post while you are writing one).
So:
ftp LIST and determine highest number
download
edit
ftp LIST see if there is a new upload --Note check for the highest number (maybe 2 or 3 ppl have responded before you)
If Yes then
download, append, ask if it still looks good
(increment filename by 1) upload
else
Just upload the new file
The incremental numbering ensures that if they do not get </endtag> then download the next lower number filename and also you will have a back-up trail of files.
Darn I should be using a flow chart...
There is still the possibility of data collision (both upload 003_data.txt at the same time).
and there's your hack of the day.
If you need me to explain more just ask.
Simon

I'll start by saying there is a troubled mode to my idea. User 1 and User 2 download and edit the file at the same time... Now if you can live with a sad workaround to that read on...
Oh, before you stop reading, mySQL is the one you want for online multi-user.
User 1 downloads 001_data.txt edits it and uploads 002_data.txt
User 2 ftp "LIST"'s the folders content and figures out the highest number (002_data.txt) downloads that, edit, uploads 003_data.txt.
Now everybody is going through User 2 process until the trouble starts and this is the 3rd action. ftp "LIST" before the upload and determine if there is a file by that name already. Here is where the problem is. How to merge the 2 new files?
Well you could download the file and just append the new txt to the doc I guess. Show them the new file with the append and ask if they wish to continue. (Kind of like what they do here if someone has replied to a post while you are writing one).
So:
ftp LIST and determine highest number
download
edit
ftp LIST see if there is a new upload --Note check for the highest number (maybe 2 or 3 ppl have responded before you)
If Yes then
download, append, ask if it still looks good
(increment filename by 1) upload
else
Just upload the new file
The incremental numbering ensures that if they do not get </endtag> then download the next lower number filename and also you will have a back-up trail of files.
Darn I should be using a flow chart...

There is still the possibility of data collision (both upload 003_data.txt at the same time).
and there's your hack of the day.


Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!