From dee14ba38f26131968c44c74a74eddc3cbff1aa6 Mon Sep 17 00:00:00 2001 From: Jungki Kwak Date: Wed, 5 Sep 2012 18:50:44 +0900 Subject: [PATCH] Add to search download id from history db [Title] Add to search download id from history db [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] If client restart the download after stoping it, the download id is exised at history db. modified: src/download-provider-db.c modified: src/download-provider-receiver.c Change-Id: I7ce0c30b6cf0ea3c3ccf5f3ad629f364b8585601 --- src/download-provider-db.c | 1 + src/download-provider-receiver.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/download-provider-db.c b/src/download-provider-db.c index 5e63b3a..f72ca59 100644 --- a/src/download-provider-db.c +++ b/src/download-provider-db.c @@ -1031,6 +1031,7 @@ download_dbinfo *download_provider_db_history_get_info(int requestid) if ((errorcode = sqlite3_step(stmt)) == SQLITE_ROW) { dbinfo = (download_dbinfo *) calloc(1, sizeof(download_dbinfo)); dbinfo->requestid = requestid; + TRACE_DEBUG_INFO_MSG("found id from db [%d]", requestid); buffer = (char *)(sqlite3_column_text(stmt, 0)); dbinfo->packagename = NULL; if (buffer) { diff --git a/src/download-provider-receiver.c b/src/download-provider-receiver.c index ed72158..a2146b5 100644 --- a/src/download-provider-receiver.c +++ b/src/download-provider-receiver.c @@ -392,12 +392,24 @@ int _handle_new_connection(download_clientinfo_slot *clientinfo_list, download_c request_clientinfo->requestinfo->requestid); if (searchindex < 0) { TRACE_DEBUG_INFO_MSG("Not Found Same Request ID"); - // Invalid id - request_clientinfo->state = DOWNLOAD_STATE_FAILED; - request_clientinfo->err = DOWNLOAD_ERROR_INVALID_PARAMETER; - ipc_send_request_stateinfo(request_clientinfo); - clear_clientinfo(request_clientinfo); - return 0; + /* Try to search history db */ + download_dbinfo *dbinfo = download_provider_db_history_get_info( + request_clientinfo->requestinfo->requestid); + if (dbinfo == NULL) { + /* Try to serach downloading db. The crashed job can not be uploaded to memory */ + dbinfo = download_provider_db_get_info( + request_clientinfo->requestinfo->requestid); + if (dbinfo == NULL) { + /* Invalid id */ + request_clientinfo->state = DOWNLOAD_STATE_FAILED; + request_clientinfo->err = DOWNLOAD_ERROR_INVALID_PARAMETER; + ipc_send_request_stateinfo(request_clientinfo); + clear_clientinfo(request_clientinfo); + return 0; + } + } + download_provider_db_info_free(dbinfo); + free(dbinfo); } else { // found request id. // how to deal etag ? // connect to slot. TRACE_DEBUG_INFO_MSG("Found Same Request ID slot[%d]", searchindex); -- 2.7.4