Commit e2237e2e authored by Tobias Ellinghaus's avatar Tobias Ellinghaus

Fix #12040: Add some error handling

Thank you Zhouyang Jia for finding these and proposing the patch.

(cherry picked from commit 052649e9)
parent 62182ffa
......@@ -221,6 +221,7 @@ int dt_film_import(const char *dirname)
{
int rc;
sqlite3_stmt *stmt;
GError *error = NULL;
/* initialize a film object*/
dt_film_t *film = (dt_film_t *)malloc(sizeof(dt_film_t));
......@@ -282,7 +283,15 @@ int dt_film_import(const char *dirname)
g_strlcpy(film->dirname, dirname, sizeof(film->dirname));
char *last = &film->dirname[strlen(film->dirname) - 1];
if(*last == '/' && last != film->dirname) *last = '\0'; // remove the closing /, unless it's also the start
film->dir = g_dir_open(film->dirname, 0, NULL);
film->dir = g_dir_open(film->dirname, 0, &error);
if(error)
{
fprintf(stderr, "[film_import] failed to open directory %s: %s\n", film->dirname, error->message);
g_error_free(error);
dt_film_cleanup(film);
free(film);
return 0;
}
dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_BG, dt_film_import1_create(film));
return filmid;
......
......@@ -505,10 +505,16 @@ static const gchar *picasa_upload_photo_to_album(PicasaContext *ctx, gchar *albu
curl_easy_setopt(ctx->curl_ctx, CURLOPT_WRITEFUNCTION, _picasa_api_buffer_write_func);
curl_easy_setopt(ctx->curl_ctx, CURLOPT_WRITEDATA, &buffer);
curl_easy_perform(ctx->curl_ctx);
int res = curl_easy_perform(ctx->curl_ctx);
curl_slist_free_all(headers);
if(res != CURLE_OK)
{
fprintf(stderr, "[picasa] error uploading photo: %s\n", curl_easy_strerror(res));
return NULL;
}
#ifdef picasa_EXTRA_VERBOSE
printf("Uploading: %s\n", buffer.data);
#endif
......@@ -607,7 +613,10 @@ static const gchar *picasa_upload_photo_to_album(PicasaContext *ctx, gchar *albu
curl_easy_setopt(ctx->curl_ctx, CURLOPT_READFUNCTION, _picasa_api_buffer_read_func);
curl_easy_setopt(ctx->curl_ctx, CURLOPT_WRITEFUNCTION, _picasa_api_buffer_write_func);
curl_easy_setopt(ctx->curl_ctx, CURLOPT_WRITEDATA, &response);
curl_easy_perform(ctx->curl_ctx);
res = curl_easy_perform(ctx->curl_ctx);
if(res != CURLE_OK)
fprintf(stderr, "[picasa] error updating photo: %s\n", curl_easy_strerror(res));
#ifdef picasa_EXTRA_VERBOSE
printf("Uploading: %s\n", response.data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment