Compare commits

...

3 Commits

2 changed files with 24 additions and 2 deletions

View File

@ -39,7 +39,7 @@ using namespace ARDOUR;
using std::string;
LibraryDownloadDialog::LibraryDownloadDialog ()
: ArdourDialog (_("Loop Library Manager"), true) /* modal */
: ArdourDialog (_("Loop Download Manager"), true) /* modal */
, inflater(0)
{
_model = Gtk::ListStore::create (_columns);
@ -208,8 +208,14 @@ LibraryDownloadDialog::download (Gtk::TreePath const & path)
{
Gtk::TreeModel::iterator row = _model->get_iter (path);
std::string url = (*row)[_columns.url];
PBD::Downloader* downloader;
PBD::Downloader* downloader = new PBD::Downloader (url, ARDOUR::Config->get_clip_library_dir());
try {
downloader = new PBD::Downloader (url, ARDOUR::Config->get_clip_library_dir());
} catch (...) {
(*row)[_columns.install] = _("Error");
return;
}
/* setup timer callback to update progressbar */

View File

@ -16,11 +16,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <cstring>
#include <cerrno>
#include <glib/gstdio.h>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include "pbd/compose.h"
#include "pbd/failed_constructor.h"
#include "pbd/downloader.h"
#include "pbd/error.h"
#include "pbd/i18n.h"
@ -64,6 +69,17 @@ Downloader::Downloader (string const & u, string const & dir)
, _download_size (0)
, _downloaded (0)
{
if (!Glib::file_test (destdir, Glib::FILE_TEST_EXISTS)) {
if (g_mkdir_with_parents (destdir.c_str(), 0700) != 0) {
error << string_compose (_("Could not create clip library dir %1 (%2)"), destdir, strerror(errno)) << endmsg;
throw failed_constructor();
}
} else {
if (!Glib::file_test (destdir, Glib::FILE_TEST_IS_DIR)) {
error << string_compose (_("Clip library dir (%1) is not a directory"), destdir) << endmsg;
throw failed_constructor();
}
}
}
Downloader::~Downloader ()