commit fc96f02
default
·
2022-11-23 18:03:21 +0000 UTC
parent 095a8b1
New function object_get_by_md5().
1 files changed,
+11,
-4
M
data.c
M
data.c
+11,
-4
1@@ -211,11 +211,11 @@ d_char *_object_fn(const char *id)
2 }
3
4
5-int object_get(const char *id, d_char **obj, const char *type)
6+int object_get_by_md5(const char *md5, d_char **obj, const char *type)
7 /* returns a loaded object, optionally of the requested type */
8 {
9 int status = 404;
10- xs *fn = _object_fn(id);
11+ xs *fn = _object_fn_by_md5(md5);
12 FILE *f;
13
14 if ((f = fopen(fn, "r")) != NULL) {
15@@ -243,12 +243,19 @@ int object_get(const char *id, d_char **obj, const char *type)
16 else
17 *obj = NULL;
18
19- srv_debug(2, xs_fmt("object_get %s %d", id, status));
20-
21 return status;
22 }
23
24
25+int object_get(const char *id, d_char **obj, const char *type)
26+/* returns a loaded object, optionally of the requested type */
27+{
28+ xs *md5 = xs_md5_hex(id, strlen(id));
29+
30+ return object_get_by_md5(md5, obj, type);
31+}
32+
33+
34 int object_add(const char *id, d_char *obj)
35 /* stores an object */
36 {