Skip to content

Commit

Permalink
Debugging git package download
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Nov 5, 2023
1 parent 08a790d commit 4e00a91
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/lay/lay/laySalt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
17 changes: 14 additions & 3 deletions src/tl/tl/tlGit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
2 changes: 1 addition & 1 deletion src/tl/tl/tlGit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/tl/tl/tlWebDAV.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4e00a91

Please sign in to comment.