diff options
Diffstat (limited to 'src/analysis/db/collection.c')
-rw-r--r-- | src/analysis/db/collection.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/analysis/db/collection.c b/src/analysis/db/collection.c index 1afe96b..117a2d5 100644 --- a/src/analysis/db/collection.c +++ b/src/analysis/db/collection.c @@ -306,7 +306,7 @@ bool g_db_collection_recv(GDbCollection *collec, int fd, sqlite3 *db) if (result) { - if (collec->binary != NULL) + if (collec->binary != NULL && g_db_item_is_active(item)) result = g_db_item_apply(item, collec->binary); if (db != NULL) result &= g_db_collection_store_item(collec, item, db); @@ -337,7 +337,7 @@ bool g_db_collection_recv(GDbCollection *collec, int fd, sqlite3 *db) if (g_db_item_is_active(G_DB_ITEM(found->data))) { inactive = _g_db_collection_compute_inactivity_timestamp(collec, false); - result = _g_db_collection_update_item_activity(collec, item, inactive, false); + result = _g_db_collection_update_item_activity(collec, item, &inactive, false); } } @@ -350,7 +350,15 @@ bool g_db_collection_recv(GDbCollection *collec, int fd, sqlite3 *db) case DBA_CHANGE_STATE: if (db == NULL) - result = g_db_collection_update_item_activity(collec, item, g_db_item_get_timestamp(item) + 1); + { + if (g_db_item_is_active(item)) + result = g_db_collection_update_item_activity(collec, item, NULL); + else + { + inactive = g_db_item_get_timestamp(item) + 1; + result = g_db_collection_update_item_activity(collec, item, &inactive); + } + } else result = false; @@ -716,7 +724,7 @@ timestamp_t _g_db_collection_compute_inactivity_timestamp(GDbCollection *collec, * * ******************************************************************************/ -bool _g_db_collection_update_item_activity(GDbCollection *collec, GDbItem *item, timestamp_t timestamp, bool lock) +bool _g_db_collection_update_item_activity(GDbCollection *collec, GDbItem *item, timestamp_t *timestamp, bool lock) { bool result; /* Bilan à faire remonter */ GList *found; /* Test de présence existante */ @@ -733,7 +741,7 @@ bool _g_db_collection_update_item_activity(GDbCollection *collec, GDbItem *item, { internal = G_DB_ITEM(found->data); - g_db_item_set_activity(internal, (timestamp_t []) { timestamp }); + result = g_db_item_set_activity(internal, collec->binary, timestamp); g_signal_emit_by_name(collec, "content-changed", DBA_CHANGE_STATE, internal); @@ -780,7 +788,7 @@ GList *g_db_collection_set_last_active(GDbCollection *collec, timestamp_t timest { if (!g_db_item_is_active(item)) { - g_db_item_set_activity(item, NULL); + /* ... */g_db_item_set_activity(item, collec->binary, NULL); /* ... */g_db_collection_store_updated_item(collec, item, db); g_signal_emit_by_name(collec, "content-changed", DBA_CHANGE_STATE, item); } @@ -823,16 +831,16 @@ GList *g_db_collection_set_last_active(GDbCollection *collec, timestamp_t timest bool g_db_collection_set_inactive(GDbCollection *collec, GDbItem *item, timestamp_t *timestamp) { + bool result; /* Bilan à retourner */ + /* Si cette collection n'est pas concernée, on ne bouge pas ! */ if (G_OBJECT_TYPE(G_OBJECT(item)) != collec->type) return false; - assert(g_db_item_is_active(item)); - - g_db_item_set_activity(item, timestamp); + result = g_db_item_set_activity(item, collec->binary, timestamp); g_signal_emit_by_name(collec, "content-changed", DBA_CHANGE_STATE, item); - return true; + return result; } |