From 76f44c6025da10e97560890c4147857fbbdcbc4d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 8 Sep 2022 18:18:53 -0600 Subject: [PATCH] library mgmt API tweaks --- libs/ardour/ardour/library.h | 1 + libs/ardour/library.cc | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/library.h b/libs/ardour/ardour/library.h index 9a1cf5b979..308fda3155 100644 --- a/libs/ardour/ardour/library.h +++ b/libs/ardour/ardour/library.h @@ -63,6 +63,7 @@ class LibraryDescription class Downloader { public: Downloader (std::string const & url, std::string const & destdir); + ~Downloader (); int start (); void cleanup (); diff --git a/libs/ardour/library.cc b/libs/ardour/library.cc index 8fff83529b..7ba38f765c 100644 --- a/libs/ardour/library.cc +++ b/libs/ardour/library.cc @@ -22,6 +22,7 @@ #include #include +#include "pbd/error.h" #include "pbd/i18n.h" #include "pbd/file_archive.h" #include "pbd/replace_all.h" @@ -240,6 +241,11 @@ Downloader::Downloader (string const & u, string const & dir) { } +Downloader::~Downloader () +{ + cleanup(); +} + int Downloader::start () { @@ -266,7 +272,6 @@ void Downloader::cancel () { _cancel = true; - cleanup (); } double @@ -278,6 +283,8 @@ Downloader::progress () const void Downloader::download () { + char curl_error[CURL_ERROR_SIZE]; + { /* First curl fetch to get the data size so that we can offer a * progress meter @@ -291,9 +298,11 @@ Downloader::download () /* get size */ + curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); curl_easy_setopt(curl, CURLOPT_HEADER, 0L); curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, curl_error); CURLcode res = curl_easy_perform (curl); @@ -306,6 +315,7 @@ Downloader::download () curl_easy_cleanup (curl); if (res != CURLE_OK ) { + error << string_compose (_("Download failed, error code %1 (%2)"), curl_easy_strerror (res), curl_error) << endmsg; _status = -2; return; }