summaryrefslogtreecommitdiff
path: root/src/lib/ethumb
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-19 16:04:52 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-19 22:13:09 +0900
commit51cebf64e9ba6dafe0dcc0d43a9d2b8726f549df (patch)
tree82d8fbd90bf7727de732be8a5ff6e899c8ba138f /src/lib/ethumb
parentdfb5c03ce059ebb3b736309ee01cd096bdd0839a (diff)
ethumb - fix clients going right to disk and getting half written thumbs
client still do stats (not async) but at least they dont get half-baked thumbs now
Diffstat (limited to 'src/lib/ethumb')
-rw-r--r--src/lib/ethumb/ethumb.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/ethumb/ethumb.c b/src/lib/ethumb/ethumb.c
index 35163c1391..761d56d5a7 100644
--- a/src/lib/ethumb/ethumb.c
+++ b/src/lib/ethumb/ethumb.c
@@ -1363,8 +1363,8 @@ EAPI Eina_Bool
1363ethumb_image_save(Ethumb *e) 1363ethumb_image_save(Ethumb *e)
1364{ 1364{
1365 Eina_Bool r; 1365 Eina_Bool r;
1366 char *dname; 1366 char *dname, *buf, flags[256];
1367 char flags[256]; 1367 int len;
1368 1368
1369 EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0); 1369 EINA_SAFETY_ON_NULL_RETURN_VAL(e, 0);
1370 1370
@@ -1388,18 +1388,28 @@ ethumb_image_save(Ethumb *e)
1388 free(dname); 1388 free(dname);
1389 return EINA_FALSE; 1389 return EINA_FALSE;
1390 } 1390 }
1391 buf = alloca(strlen(e->thumb_path) + 1 + 5);
1392 strcpy(buf, dname);
1393 len = strlen(dname);
1394 strcpy(&(buf[len]), "/.tmp.");
1395 strcpy(&(buf[len + 6]), e->thumb_path + len + 1);
1391 free(dname); 1396 free(dname);
1392 1397
1393 snprintf(flags, sizeof(flags), "quality=%d compress=%d", 1398 snprintf(flags, sizeof(flags), "quality=%d compress=%d",
1394 e->quality, e->compress); 1399 e->quality, e->compress);
1395 r = evas_object_image_save(e->o, e->thumb_path, e->thumb_key, flags); 1400 r = evas_object_image_save(e->o, buf, e->thumb_key, flags);
1396
1397 if (!r) 1401 if (!r)
1398 { 1402 {
1399 ERR("could not save image: path=%s, key=%s", e->thumb_path, 1403 ERR("could not save image: path=%s, key=%s", e->thumb_path,
1400 e->thumb_key); 1404 e->thumb_key);
1401 return EINA_FALSE; 1405 return EINA_FALSE;
1402 } 1406 }
1407 if (rename(buf, e->thumb_path) < 0)
1408 {
1409 ERR("could not rename image: path=%s, key=%s to path=%s",
1410 buf, e->thumb_key, e->thumb_path);
1411 return EINA_FALSE;
1412 }
1403 1413
1404 return EINA_TRUE; 1414 return EINA_TRUE;
1405} 1415}