From 40334d2dec0545100edcca403d50ad6b1b015a9a Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 25 Apr 2009 15:39:55 +0200 Subject: Update mode By doing update, cgg will check the output structure for missing files and re-generate them as necessary. The decision whether an item (file, picture, album) needs to be updated is done by comparing timestamps (mtime specifically). Due to that reason it's important to keep this fact in mind when replacing single image which carries older timestamp than other files. Either don't use the update mode or 'touch' that new file. Changes made to any XML file will result in whole album re-generation (excluding subalbums). --- src/cgg.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/cgg.c') diff --git a/src/cgg.c b/src/cgg.c index f5776b4..aa8a2ab 100644 --- a/src/cgg.c +++ b/src/cgg.c @@ -44,19 +44,21 @@ * parse_cmd: parse commandline and fill global variable parameters */ gboolean -parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *verbose, int *jobs) +parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *verbose, int *jobs, gboolean *update) { static gboolean _verbose = FALSE; static gchar *_source_dir = NULL; static gchar *_dst_dir = NULL; static int _jobs = 1; + static gboolean _update = FALSE; static GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose, "Be verbose", NULL }, - { "source", 's', 0, G_OPTION_ARG_STRING, &_source_dir, "Specifies path to source structure", NULL }, + { "source", 's', 0, G_OPTION_ARG_STRING, &_source_dir, "Specifies a path to source structure", NULL }, { "output", 'o', 0, G_OPTION_ARG_STRING, &_dst_dir, "Generate files to the specified directory instead of current", NULL }, { "jobs", 'j', 0, G_OPTION_ARG_INT, &_jobs, "Allow N jobs at once (default=1)", NULL }, + { "update", 'u', 0, G_OPTION_ARG_NONE, &_update, "Update the output structure", NULL }, { NULL } }; @@ -73,7 +75,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * g_option_context_add_main_entries (context, entries, NULL); if (argc == 1) { - s1 = g_option_context_get_help (context, TRUE, NULL); + s1 = g_option_context_get_help (context, TRUE, NULL); g_print ("%s", s1); g_free (s1); g_option_context_free (context); @@ -82,7 +84,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * if (! g_option_context_parse (context, &argc, &argv, &error)) { g_print ("option parsing failed: %s\n", error->message); - s1 = g_option_context_get_help (context, TRUE, NULL); + s1 = g_option_context_get_help (context, TRUE, NULL); g_print ("%s", s1); g_free (s1); g_option_context_free (context); @@ -94,6 +96,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * *dst_dir = _dst_dir; *verbose = _verbose; *jobs = _jobs; + *update = _update; return TRUE; } @@ -106,6 +109,7 @@ main(int argc, char* argv[]) char *source_dir; char *dst_dir; gboolean verbose; + gboolean update; int jobs; TGallerySetup *setup; time_t time_start = time (NULL); @@ -130,7 +134,7 @@ main(int argc, char* argv[]) /* Parse commandline */ - if (! parse_cmd (argc, argv, &source_dir, &dst_dir, &verbose, &jobs)) + if (! parse_cmd (argc, argv, &source_dir, &dst_dir, &verbose, &jobs, &update)) return -1; if ((! source_dir) || (access (source_dir, R_OK))) { @@ -165,6 +169,7 @@ main(int argc, char* argv[]) /* Start building the gallery tree */ setup->verbose = verbose; + setup->update_mode = update; build_tree (setup, source_dir, dst_dir, NULL, -1, jobs); if (verbose) { -- cgit v1.2.3