forked from enlightenment/efl
ethumb: use xattr as cache when available.
SVN revision: 59004
This commit is contained in:
parent
7280b0d852
commit
c5b107f144
|
@ -195,6 +195,27 @@ fi
|
||||||
AM_CONDITIONAL(HAVE_LIBEXIF, test $HAVE_LIBEXIF = yes)
|
AM_CONDITIONAL(HAVE_LIBEXIF, test $HAVE_LIBEXIF = yes)
|
||||||
AC_SUBST(HAVE_LIBEXIF)
|
AC_SUBST(HAVE_LIBEXIF)
|
||||||
|
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[[
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
]],
|
||||||
|
[[
|
||||||
|
size_t tmp = listxattr("/", NULL, 0);
|
||||||
|
tmp = getxattr("/", "user.ethumb.md5", NULL, 0);
|
||||||
|
setxattr("/", "user.ethumb.md5", NULL, 0, 0);
|
||||||
|
]])],
|
||||||
|
[
|
||||||
|
AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if you have 'listxattr', 'setxattr' and 'getxattr'])
|
||||||
|
have_xattr="yes"
|
||||||
|
],
|
||||||
|
[have_xattr="no"])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for Xattr])
|
||||||
|
AC_MSG_RESULT([${have_xattr}])
|
||||||
|
|
||||||
AC_SUBST(requirement_ethumb)
|
AC_SUBST(requirement_ethumb)
|
||||||
AC_SUBST(requirement_ethumb_client)
|
AC_SUBST(requirement_ethumb_client)
|
||||||
AC_SUBST(dbusservicedir)
|
AC_SUBST(dbusservicedir)
|
||||||
|
@ -248,6 +269,7 @@ Summary:
|
||||||
|
|
||||||
Configuration Options Summary:
|
Configuration Options Summary:
|
||||||
|
|
||||||
|
* use xattr........: ${have_xattr}
|
||||||
* maximum log level: ${with_max_log_level}
|
* maximum log level: ${with_max_log_level}
|
||||||
* documentation....: ${build_doc}
|
* documentation....: ${build_doc}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,10 @@ void *alloca (size_t);
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
|
# include <sys/xattr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
# define PATH_MAX 4096
|
# define PATH_MAX 4096
|
||||||
#endif
|
#endif
|
||||||
|
@ -824,6 +828,27 @@ _ethumb_generate_hash(const char *file)
|
||||||
char *t;
|
char *t;
|
||||||
const unsigned char *c;
|
const unsigned char *c;
|
||||||
|
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
|
ssize_t length;
|
||||||
|
|
||||||
|
length = getxattr(file, "user.e.md5", NULL, 0);
|
||||||
|
|
||||||
|
if (length > 0)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
tmp = alloca(length);
|
||||||
|
length = getxattr(file, "user.e.md5", tmp, length);
|
||||||
|
|
||||||
|
/* check if we have at least something that look like a md5 hash */
|
||||||
|
if (length > 0 && (length == MD5_HASHBYTES * 2 + 1))
|
||||||
|
{
|
||||||
|
tmp[length] = '\0';
|
||||||
|
return eina_stringshare_add(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _check_uri_char(c) \
|
#define _check_uri_char(c) \
|
||||||
((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
|
((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
|
||||||
|
|
||||||
|
@ -859,6 +884,10 @@ _ethumb_generate_hash(const char *file)
|
||||||
}
|
}
|
||||||
md5out[2 * n] = '\0';
|
md5out[2 * n] = '\0';
|
||||||
|
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
|
setxattr(file, "user.e.md5", md5out, 2 * n + 1, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
DBG("md5=%s, file=%s", md5out, file);
|
DBG("md5=%s, file=%s", md5out, file);
|
||||||
return eina_stringshare_add(md5out);
|
return eina_stringshare_add(md5out);
|
||||||
}
|
}
|
||||||
|
@ -924,7 +953,6 @@ _ethumb_file_generate_path(Ethumb *e)
|
||||||
const char *ext;
|
const char *ext;
|
||||||
int fdo_format;
|
int fdo_format;
|
||||||
|
|
||||||
|
|
||||||
fdo_format = _ethumb_file_check_fdo(e);
|
fdo_format = _ethumb_file_check_fdo(e);
|
||||||
|
|
||||||
if (e->thumb_dir)
|
if (e->thumb_dir)
|
||||||
|
@ -957,7 +985,6 @@ _ethumb_file_generate_path(Ethumb *e)
|
||||||
else
|
else
|
||||||
ext = "eet";
|
ext = "eet";
|
||||||
|
|
||||||
|
|
||||||
fullname = ecore_file_realpath(e->src_path);
|
fullname = ecore_file_realpath(e->src_path);
|
||||||
hash = _ethumb_generate_hash(fullname);
|
hash = _ethumb_generate_hash(fullname);
|
||||||
snprintf(buf, sizeof(buf), "%s/%s/%s.%s", thumb_dir, category, hash, ext);
|
snprintf(buf, sizeof(buf), "%s/%s/%s.%s", thumb_dir, category, hash, ext);
|
||||||
|
|
Loading…
Reference in New Issue