is_new attribute added to the torrent state information
[qtrapids] / src / server / TorrentSession.cpp
index 514b2c9..6158452 100644 (file)
@@ -48,10 +48,17 @@ namespace qtrapids
 
 
             if (ta) {
+
+                if (!ta->handle.is_valid()) {
+                    qDebug() << "handle is invalid";
+                    return;
+                }
+
                 TorrentHandle handle(ta->handle);
                 TorrentState state;
 
                 state.hash = Hash2QStr(handle.hash());
+                state.is_new = false;
                 state.state = handle.state();
                 state.progress = handle.progress() * torrent_progress_max;
                 state.down_rate = handle.downloadRate();
@@ -76,6 +83,7 @@ namespace qtrapids
             
             state.hash = hash;
             state.name = handle->name();
+            state.is_new = true;
             state.state = handle->state();
             state.progress = handle->progress() * torrent_progress_max;
             state.down_rate = handle->downloadRate();
@@ -100,11 +108,12 @@ namespace qtrapids
 
         qDebug() << "addTorrent: " << path << " save to " << save_path;
         boost::intrusive_ptr<libtorrent::torrent_info> tiTmp
-            = new libtorrent::torrent_info(path.toStdString());
+            = new libtorrent::torrent_info
+            (boost::filesystem::path(path.toStdString()));
         addParams.ti = tiTmp;
 
         // save_path is the only mandatory parameter, rest are optional.
-        addParams.save_path = save_path.toStdString();
+        addParams.save_path = boost::filesystem::path(save_path.toStdString());
         //addParams.storage_mode = libtorrent::storage_mode_allocate;
 
         TorrentHandlePtr handle(new TorrentHandle(btSession_.add_torrent(addParams)));
@@ -114,6 +123,7 @@ namespace qtrapids
 
         state.hash = hash;
         state.name = handle->name();
+        state.is_new = true;
         state.state = handle->state();
         state.progress = handle->progress() * torrent_progress_max;
         state.down_rate = handle->downloadRate();