0

I have a problem which is a bit hard to describe. I'm writing a script to update an online program that I built. To update, I download a tar.gz files, extract it and then replace all old files with the ones from the update. To keep the user updated about the update progress, I have a progress bar, which is updated using jQuery ajax. This is the progress step by step, after each step, the progress bar is updated:

  1. An ajax call is made to download the update package

  2. An ajax call is made to extract the package

  3. An ajax call is made to replace all old files with new ones

  4. Update is installed

My problem is, when the update process comes to step 3, I get a javascript error Failed to load resource: The request timed out.. I think that this is because I replace all javascript and php files as well. How can I make this ajax call working, or some other nice way to update the progress bar while the update is busy being installed?

  • Consider a [*long polling*](http://stackoverflow.com/questions/333664/simple-long-polling-example-code) as one of the possible ways. – BlitZ Jan 21 '14 at 06:49

1 Answers1

0

Can you dig in a bit more on how you do it?

  • are you able to temporarily load all script (js and php) files for the update into an temp folder and load them from there? You can delete the files in the temp folder as soon as you have updated the 'core' files.
  • did you check if step 3 itself is successful? The files get replaced, but the status doesn't update? Or does the replacement itself fail as well?

Update:

regarding the time out ... How exactly does your replacement work?

Do you have a function which sends several calls? Or do you make one huge call?

Also, did you try to call the php manualy which makes the actual update work in the background? If so, did it also have an timeout?

If you can't use a temp directory, it could also be possible that all the files you try to replace are 'blocked' because they are used. But this is just a guess.

If not yet done, try to rewrite the function which makes the actual updates and replacements. Let either the js or the php:

  1. check how many files need an update
  2. set a counter to that number and an array with the files
  3. for each counter update one file
  4. maybe try do some comparisons before/after
  • I can't put all files in some temp directory and work out from there. I checked step 3, I placed all files that are replaced in a txt file and compared that to the files that needed to be replaced. –  Jan 21 '14 at 10:52