diff --git a/src/lay/lay/laySalt.cc b/src/lay/lay/laySalt.cc index 81267fa977..efb77844e1 100644 --- a/src/lay/lay/laySalt.cc +++ b/src/lay/lay/laySalt.cc @@ -497,25 +497,25 @@ Salt::create_grain (const SaltGrain &templ, SaltGrain &target, double timeout, t } else if (! templ.url ().empty ()) { - if (templ.url ().find ("http:") == 0 || templ.url ().find ("https:") == 0) { + lay::SaltParsedURL purl (templ.url ()); - // otherwise download from the URL using Git or SVN + if (purl.url ().find ("http:") == 0 || purl.url ().find ("https:") == 0) { - lay::SaltParsedURL purl (templ.url ()); + // otherwise download from the URL using Git or SVN if (purl.protocol () == Git) { #if defined(HAVE_GIT2) - tl::info << QObject::tr ("Downloading package from '%1' to '%2' using Git protocol ..").arg (tl::to_qstring (templ.url ())).arg (tl::to_qstring (target.path ())); - res = tl::GitObject::download (templ.url (), target.path (), purl.subfolder (), purl.branch (), timeout, callback); + tl::info << QObject::tr ("Downloading package from '%1' to '%2' using Git protocol (ref='%3', subdir='%4') ..").arg (tl::to_qstring (purl.url ())).arg (tl::to_qstring (target.path ())).arg (tl::to_qstring (purl.branch ())).arg (tl::to_qstring (purl.subfolder ())); + res = tl::GitObject::download (purl.url (), target.path (), purl.subfolder (), purl.branch (), timeout, callback); #else throw tl::Exception (tl::to_string (QObject::tr ("Unable to install package '%1' - git protocol not compiled in").arg (tl::to_qstring (target.name ())))); #endif } else if (purl.protocol () == WebDAV || purl.protocol () == DefaultProtocol) { - tl::info << QObject::tr ("Downloading package from '%1' to '%2' using SVN/WebDAV protocol ..").arg (tl::to_qstring (templ.url ())).arg (tl::to_qstring (target.path ())); - res = tl::WebDAVObject::download (templ.url (), target.path (), timeout, callback); + tl::info << QObject::tr ("Downloading package from '%1' to '%2' using SVN/WebDAV protocol ..").arg (tl::to_qstring (purl.url ())).arg (tl::to_qstring (target.path ())); + res = tl::WebDAVObject::download (purl.url (), target.path (), timeout, callback); } diff --git a/src/tl/tl/tlGit.cc b/src/tl/tl/tlGit.cc index 050243abc5..6810b07ea6 100644 --- a/src/tl/tl/tlGit.cc +++ b/src/tl/tl/tlGit.cc @@ -384,9 +384,20 @@ GitObject::read (const std::string &org_url, const std::string &org_filter, cons bool GitObject::download (const std::string &url, const std::string &target, const std::string &subfolder, const std::string &branch, double timeout, tl::InputHttpStreamCallback *callback) { - GitObject obj (target); - obj.read (url, std::string (), subfolder, branch, timeout, callback); - return false; + try { + + GitObject obj (target); + obj.read (url, std::string (), subfolder, branch, timeout, callback); + + return true; + + } catch (tl::Exception &ex) { + + tl::error << tl::sprintf (tl::to_string (tr ("Error downloading Git repo from %s (subdir '%s', ref '%s')")), url, subfolder, branch); + + return false; + + } } tl::InputStream * diff --git a/src/tl/tl/tlGit.h b/src/tl/tl/tlGit.h index a5d22e342c..a99d304499 100644 --- a/src/tl/tl/tlGit.h +++ b/src/tl/tl/tlGit.h @@ -79,7 +79,7 @@ class TL_PUBLIC GitObject * * Sub-directories are created if required. * - * This method throws an exception if the directory structure could + * This method returns false if the directory structure could * not be obtained or downloading of one file failed. * * "branch" is the remote ref to use. This can be a branch name, a tag name, diff --git a/src/tl/tl/tlWebDAV.h b/src/tl/tl/tlWebDAV.h index 5b676a2a7c..7a63f6a367 100644 --- a/src/tl/tl/tlWebDAV.h +++ b/src/tl/tl/tlWebDAV.h @@ -145,7 +145,7 @@ class TL_PUBLIC WebDAVObject * * Sub-directories are created if required. * - * This method throws an exception if the directory structure could + * This method returns false if the directory structure could * not be obtained or downloading of one file failed. */ static bool download (const std::string &url, const std::string &target, double timeout = 60.0, tl::InputHttpStreamCallback *callback = 0);