]> Pileus Git - ~andy/ct/commitdiff
Add timestamp checking master
authorAndy Spencer <andy753421@gmail.com>
Wed, 14 Aug 2013 05:44:05 +0000 (05:44 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 14 Aug 2013 05:44:13 +0000 (05:44 +0000)
gallery/gallery.c

index 5b727dc1f3f5a4030f08a0737f6571f0a2a2e0f8..df9a37d4e6f89dada3d551e718c398396402074c 100644 (file)
@@ -5,10 +5,15 @@
 
 void resize(gchar *orig, gchar *thumb, gchar *size)
 {
-       gchar *argv[] = {"convert", "-resize", size, orig, thumb, NULL};
-       /* god damn glib */
-       g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
-               NULL, NULL, NULL, NULL, NULL, NULL);
+       GStatBuf oinfo, tinfo;
+       int oval = g_stat(orig,  &oinfo);
+       int tval = g_stat(thumb, &tinfo);
+       if (tval || (!oval && oinfo.st_mtime > tinfo.st_mtime)) {
+               /* god damn glib */
+               gchar *argv[] = {"convert", "-resize", size, orig, thumb, NULL};
+               g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
+                       NULL, NULL, NULL, NULL, NULL, NULL);
+       }
 }
 
 GList *gen_thumbs(GList *images)
@@ -21,10 +26,8 @@ GList *gen_thumbs(GList *images)
                gchar *large = g_build_filename("large", name, NULL);
                gchar *small = g_build_filename("small", name, NULL);
                gchar *thumb = g_build_filename("thumb", name, NULL);
-               if (!g_file_test(thumb, G_FILE_TEST_EXISTS)) {
-                       resize(large, thumb, "200x200");
-                       resize(large, small, "800x800");
-               }
+               resize(large, thumb, "200x200");
+               resize(large, small, "800x800");
                g_free(large);
                g_free(small);
                g_free(thumb);