From 2067c2fc6207341a7b650f6ea834cc4b4ce41b32 Mon Sep 17 00:00:00 2001 From: gmarik Date: Fri, 15 Jul 2011 01:24:18 -0500 Subject: [PATCH] Handle script fetching errors - make curl --fail on HTTP errors - make curl -o output to file - handle erros - silence curl output - unify curl command --- autoload/vundle/scripts.vim | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index d949c91..89b2eb4 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -60,24 +60,26 @@ func! s:display(headers, results) endf func! s:fetch_scripts(to) - let temp = shellescape(tempname()) - if has('win32') || has('win64') - let scripts_dir = fnamemodify(expand(a:to), ":h") - if !isdirectory(scripts_dir) - call mkdir(scripts_dir, "p") - endif - exec '!curl http://vim-scripts.org/api/scripts.json > '.temp. - \ '&& move /Y '.temp.' '.shellescape(a:to) - else - exec '!curl http://vim-scripts.org/api/scripts.json > '.temp. - \ '&& mkdir -p $(dirname '.shellescape(a:to).') && mv -f '.temp.' '.shellescape(a:to) + let scripts_dir = fnamemodify(expand(a:to), ":h") + if !isdirectory(scripts_dir) + call mkdir(scripts_dir, "p") endif + + silent exec '!curl --fail -s -o '.shellescape(a:to).' http://vim-scripts.org/api/scripts.json' + + if (0 != v:shell_error) + echoerr 'Error fetching scripts!' + return v:shell_error + endif + return 0 endf func! s:load_scripts(bang) let f = expand('$HOME/.vim-vundle/vim-scripts.org.json') if a:bang || !filereadable(f) - call s:fetch_scripts(f) + if 0 != s:fetch_scripts(f) + return [] + end endif return eval(readfile(f, 'b')[0]) endf