[Download] Fixed download initialization 35/281335/1
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Thu, 15 Sep 2022 10:41:42 +0000 (12:41 +0200)
committerPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Thu, 15 Sep 2022 10:41:46 +0000 (12:41 +0200)
When many downloads are taking place one after another it was possible
that uninitialized memory used for state value has a 5,6,7 status, which
caused that web api interpreted it as not valid state change, when the
'DOWNLOADING' state comes. Now this should not occur as the state is
initialized before starting a download.

Change-Id: I8c0ed0d375e512c1dcc17255f2387df70f3ddcb3

src/download/download_instance.cc

index 3a3b6c3..1281047 100644 (file)
@@ -189,7 +189,7 @@ common::PlatformResult DownloadInstance::convertError(int err, const std::string
   }
 
 void DownloadInstance::OnStateChanged(int download_id, download_state_e state, void* user_data) {
-  ScopeLogger();
+  ScopeLogger("State changed for callbackId: %d to: %d", download_id, state);
   CallbackPtr down_cb_ptr = static_cast<CallbackPtr>(user_data);
 
   // Prevent to call finished, cancelled or failed function more than once
@@ -628,6 +628,7 @@ void DownloadInstance::DownloadManagerStart(const picojson::value& args, picojso
 
   down_cb_ptr->download_id = di_ptr->download_id;
   down_cb_ptr->instance = this;
+  down_cb_ptr->state = DOWNLOAD_STATE_NONE;
 
   download_callbacks[down_cb_ptr->download_id] = down_cb_ptr;