diff options
Diffstat (limited to 'src/job-manager.c')
| -rw-r--r-- | src/job-manager.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/job-manager.c b/src/job-manager.c index c4a77e4..11beebb 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -41,7 +41,7 @@ typedef struct { TGallerySetup *setup; TAlbum *items; GList *job_items; - const gchar *dst_dir; + TPathInfo *path_info; gboolean force_update; int total_items; } TJob; @@ -113,7 +113,7 @@ thread_func (gpointer data) { TIndexItem *item; gchar *imgname; - gchar *s1, *s2, *s3; + gchar *s1, *s3; TJob *job = data; gboolean updated; GList *l; @@ -139,7 +139,7 @@ thread_func (gpointer data) /* actually do some work */ if (item != NULL && job_item != NULL) { imgname = g_path_get_basename ((item->path == NULL && item->preview) ? item->preview : item->path); - updated = generate_image (job->setup, job->items, item, job_item->real_index, job->dst_dir, ! job->force_update, &job_item->gen_thumb_portrait); + updated = generate_image (job->setup, job->items, item, job_item->real_index, job->path_info, ! job->force_update, &job_item->gen_thumb_portrait); if (updated && job->setup->verbose) { G_LOCK (items_print); @@ -149,11 +149,9 @@ thread_func (gpointer data) if (updated && job->items->type == GALLERY_TYPE_ALBUM) { s1 = g_strconcat (job->setup->real_templates_dir, "/", job->setup->template_photo, NULL); - s2 = g_strconcat (job->items->base_dir, "/", (item->path == NULL && item->preview) ? item->preview : item->path, NULL); - s3 = g_strconcat (job->dst_dir, "/", imgname, GET_EXT (job->setup->index_file_name), NULL); - write_html_image (job->setup, s1, s2, s3, item, job->items); + s3 = g_strconcat (job->path_info->dest_dir, "/", imgname, GET_EXT (job->setup->index_file_name), NULL); + write_html_image (job->setup, job->path_info, s1, s3, item, job->items); g_free (s1); - g_free (s2); g_free (s3); } g_free (imgname); @@ -175,8 +173,7 @@ thread_func (gpointer data) */ gboolean build_tree (TGallerySetup *setup, - const gchar *src_tree, - const gchar *dst_dir, + TPathInfo *path_info, TAlbum *parent_index, int parent_item_index, int jobs) @@ -200,24 +197,25 @@ build_tree (TGallerySetup *setup, TJobItem *job_item; GList *job_items; GList *l; + TPathInfo *child_path_info; - printf ("Processing directory \"%s\"\n", src_tree); + printf ("Processing directory \"%s\"\n", path_info->src_dir); stats_dirs_inc (); /* Check access permissions */ - if (access (src_tree, R_OK)) { + if (access (path_info->src_dir, R_OK)) { log_error ("error accessing source directory: %s\n", strerror (errno)); return FALSE; } - if (access (dst_dir, R_OK | W_OK | X_OK)) { - if (g_mkdir_with_parents (dst_dir, DEFAULT_DATA_DIR_MODE)) { + if (access (path_info->dest_dir, R_OK | W_OK | X_OK)) { + if (g_mkdir_with_parents (path_info->dest_dir, DEFAULT_DATA_DIR_MODE)) { log_error ("error creating destination directory: %s\n", strerror (errno)); return FALSE; } } /* Check the index file */ - idx_file = g_strconcat (src_tree, "/index.xml", NULL); + idx_file = g_strconcat (path_info->src_dir, "/index.xml", NULL); if (access (idx_file, R_OK)) { log_error ("error accessing index file '%s': %s\n", idx_file, strerror (errno)); g_free (idx_file); @@ -235,20 +233,20 @@ build_tree (TGallerySetup *setup, items->parent_item_index = parent_item_index; /* Check if update is necessary */ - dst_album_file = g_strconcat (dst_dir, "/", setup->index_file_name, NULL); + dst_album_file = g_strconcat (path_info->dest_dir, "/", setup->index_file_name, NULL); force_update = (! setup->update_mode || needs_update (idx_file, dst_album_file)); g_free (idx_file); /* Copy support files */ if (! setup->support_files_use_common_root || parent_index == NULL) { /* copy only if we're in root level or old-style is active */ - mirror_files (setup, setup->template_files, setup->real_templates_dir, dst_dir, " Copying template files: "); + mirror_files (setup, setup->template_files, setup->real_templates_dir, path_info->dest_dir, " Copying template files: "); /* favicon */ if (setup->favicon_file && strlen (setup->favicon_file) > 0) { s3 = g_path_get_dirname (setup->setup_xml_path); s1 = g_strconcat (s3, "/", setup->favicon_file, NULL); - s2 = g_strconcat (dst_dir, "/", setup->favicon_file, NULL); + s2 = g_strconcat (path_info->dest_dir, "/", setup->favicon_file, NULL); if (! setup->update_mode || needs_update (s1, s2)) { if (setup->verbose) printf (" Copying favicon: %s\n", setup->favicon_file); copy_file (s1, s2); @@ -260,7 +258,7 @@ build_tree (TGallerySetup *setup, } /* Prepare target thumbnail directory */ - thumb_dir = g_strconcat (dst_dir, "/", setup->thumbnail_dir, NULL); + thumb_dir = g_strconcat (path_info->dest_dir, "/", setup->thumbnail_dir, NULL); if (access (thumb_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (thumb_dir, DEFAULT_DATA_DIR_MODE)) { log_error ("error making target thumbnail directory: %s\n", strerror (errno)); @@ -275,8 +273,8 @@ build_tree (TGallerySetup *setup, if (items->type == GALLERY_TYPE_ALBUM) { res = TRUE; - img_big_dir = g_strconcat (dst_dir, "/", setup->img_big_dir, NULL); - img_orig_dir = g_strconcat (dst_dir, "/", setup->img_orig_dir, NULL); + img_big_dir = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, NULL); + img_orig_dir = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, NULL); if (access (img_big_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (img_big_dir, DEFAULT_DATA_DIR_MODE)) { log_error ("error making target preview directory: %s\n", strerror (errno)); @@ -300,7 +298,7 @@ build_tree (TGallerySetup *setup, job = g_malloc0 (sizeof (TJob)); job->items = items; job->setup = setup; - job->dst_dir = dst_dir; + job->path_info = path_info; job->force_update = force_update; job->total_items = 0; @@ -378,7 +376,7 @@ build_tree (TGallerySetup *setup, if (setup->verbose) printf (" Writing %s\n", setup->index_file_name); s1 = g_strconcat (setup->real_templates_dir, template, NULL); - res = write_html_album (setup, s1, dst_album_file, items); + res = write_html_album (setup, path_info, s1, dst_album_file, items); g_free (s1); g_free (template); if (! res) { @@ -400,18 +398,20 @@ build_tree (TGallerySetup *setup, continue; } if (item->type == INDEX_ITEM_TYPE_PICTURE) { - s1 = g_strconcat (src_tree, "/", item->path, "/", NULL); - s2 = g_strconcat (dst_dir, "/", item->path, "/", NULL); - build_tree (setup, s1, s2, items, i, jobs); - g_free (s1); - g_free (s2); + child_path_info = g_malloc0 (sizeof (TPathInfo)); + child_path_info->source_root = g_strdup (path_info->source_root); + child_path_info->dest_root = g_strdup (path_info->dest_root); + child_path_info->src_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->src_dir, item->path, NULL); + child_path_info->dest_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->dest_dir, item->path, NULL); + build_tree (setup, child_path_info, items, i, jobs); + free_path_info (child_path_info); } } } } /* Copy extra files */ - mirror_files (setup, items->extra_files, src_tree, dst_dir, " Copying extra files: "); + mirror_files (setup, items->extra_files, path_info->src_dir, path_info->dest_dir, " Copying extra files: "); free_album_data (items); return TRUE; |
