[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4127 - GNUnet/src/applications/dstore
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4127 - GNUnet/src/applications/dstore |
Date: |
Sat, 30 Dec 2006 06:51:15 -0800 (PST) |
Author: grothoff
Date: 2006-12-30 06:51:14 -0800 (Sat, 30 Dec 2006)
New Revision: 4127
Modified:
GNUnet/src/applications/dstore/dstore.c
Log:
do not store data twice
Modified: GNUnet/src/applications/dstore/dstore.c
===================================================================
--- GNUnet/src/applications/dstore/dstore.c 2006-12-30 14:01:37 UTC (rev
4126)
+++ GNUnet/src/applications/dstore/dstore.c 2006-12-30 14:51:14 UTC (rev
4127)
@@ -289,6 +289,7 @@
const char * data) {
sqlite3 * dbh;
sqlite3_stmt * stmt;
+ int ret;
if (size > MAX_CONTENT_SIZE)
return SYSERR;
@@ -307,6 +308,55 @@
size,
data);
#endif
+
+ /* first try UPDATE */
+ if (sq_prepare(dbh,
+ "UPDATE ds071 SET puttime=?, expire=? "
+ "WHERE key=? AND type=? AND size=? AND value=?",
+ &stmt) != SQLITE_OK) {
+ GE_LOG(coreAPI->ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "sq_prepare",
+ __FILE__,
+ __LINE__,
+ sqlite3_errmsg(dbh));
+ sqlite3_close(dbh);
+ MUTEX_UNLOCK(lock);
+ return SYSERR;
+ }
+ sqlite3_bind_int64(stmt,
+ 1,
+ get_time());
+ sqlite3_bind_int64(stmt,
+ 2,
+ discard_time);
+ sqlite3_bind_blob(stmt,
+ 3,
+ key,
+ sizeof(HashCode512),
+ SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt,
+ 4,
+ type);
+ sqlite3_bind_int(stmt,
+ 5,
+ size);
+ sqlite3_bind_blob(stmt,
+ 6,
+ data,
+ size,
+ SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
+ ret = sqlite3_changes(dbh);
+ sqlite3_finalize(stmt);
+ if (ret > 0) {
+ sqlite3_close(dbh);
+ MUTEX_UNLOCK(lock);
+ return OK;
+ }
+
+
if (OK != checkQuota(dbh)) {
sqlite3_close(dbh);
MUTEX_UNLOCK(lock);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4127 - GNUnet/src/applications/dstore,
grothoff <=