I was in the unlucky situation to be offline when I ran Drush 4 for the first time. Got the message 'Drush needs a copy of the PEAR Console_Table library ...' but when online Drush did not recover from this situation. This was caused by an empty /includes/table.inc file created by wget, which creates an empty file when exiting with a time out (OSX 10.6.6 if that matters).

CommentFileSizeAuthor
drush-recover-from-wget.patch926 bytessutharsan

Comments

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

Could not reproduce. For me, this code does the trick:

      if ($file = @file_get_contents(DRUSH_TABLE_URL)) {
        @file_put_contents($tablefile, $file);
      }

Why is it that wget/curl might sometimes work if file_get_contents does not?

I'm not saying that I don't believe the OP, I'm just confused about why that code branch is there at all. Rather than the patch in #0, I would just replace the two occurrences of if (!file_exists($tablefile)) { with if (!drush_file_not_empty($tablefile)) {. I'd commit it if I knew why it was needed at all.

Anyway, seems fine; maybe someone else can confirm and commit.

kotnik’s picture

One thing is sure, wget indeed does create empty file after it fails to download it:

$ rm test.file ; wget --tries=1 --timeout=2 -O test.file http://111.111.111.111/i.do.not.exist ; ls -l test.file
rm: cannot remove `test.file': No such file or directory
--2011-01-13 23:38:13--  http://111.111.111.111/i.do.not.exist
Connecting to 111.111.111.111:80... failed: Connection timed out.
Giving up.

-rw-r--r-- 1 kotnik kotnik 0 2011-01-13 23:38 test.file

There's no reason not to apply this patch.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

committed. thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.