From 7e175dd4c0d948399fc0928a180eaf8ceac92168 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 17 Nov 2007 03:21:34 +0000 Subject: [PATCH] remap files update --- plugins/TorrentFiles/tab_files.py | 23 ++++++++++++++++------- src/deluge_core.cpp | 23 +++++++++++++---------- src/interface.py | 14 +++++++++++--- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/plugins/TorrentFiles/tab_files.py b/plugins/TorrentFiles/tab_files.py index 91e532223..44183b0ec 100644 --- a/plugins/TorrentFiles/tab_files.py +++ b/plugins/TorrentFiles/tab_files.py @@ -123,20 +123,29 @@ an error trying to launch the file.")) selected_paths = self.file_view.get_selection().get_selected_rows()[1] try: for path in selected_paths: - child_path = self.file_store_sorted.\ + self.new_paths = [] + self.new_sizes = [] + self.child_path = self.file_store_sorted.\ convert_path_to_child_path(path) - file_name = self.file_store.get_value( - self.file_store.get_iter(child_path), 0) - file_size = self.file_store.get_value( - self.file_store.get_iter(child_path), 1) - entry.set_text(file_name) + self.file_name = self.file_store.get_value( + self.file_store.get_iter(self.child_path), 0) + self.file_size = self.file_store.get_value( + self.file_store.get_iter(self.child_path), 1) + + for x in self.manager.get_torrent_file_info(self.file_unique_id): + if x['path'] != self.file_name: + self.new_paths.append(x['path']) + self.new_sizes.append(x['size']) + entry.set_text(self.file_name) gtk.gdk.threads_enter() dlg.show_all() response = dlg.run() if response == gtk.RESPONSE_OK: new_name = entry.get_text().decode("utf_8") dlg.destroy() - self.manager.rename_file(self.file_unique_id, new_name, file_size) + self.new_paths.append(new_name) + self.new_sizes.append(self.file_size) + self.manager.rename_file(self.file_unique_id, self.new_paths, self.new_sizes) else: dlg.destroy() gtk.gdk.threads_leave() diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 75c7a19fe..d2b89a7c3 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -2027,26 +2027,29 @@ static PyObject *torrent_add_url_seed(PyObject *self, PyObject *args) static PyObject *torrent_remap_files(PyObject *self, PyObject *args) { python_long unique_ID; - const char *file_name; - float file_size; - if (!PyArg_ParseTuple(args, "isf", &unique_ID, &file_name, &file_size)) + PyObject *file_path_object; + PyObject *file_size_object; + + if (!PyArg_ParseTuple(args, "iOO", &unique_ID, &file_path_object, &file_size_object)) return NULL; long index = get_index_from_unique_ID(unique_ID); if (PyErr_Occurred()) return NULL; if (M_torrents->at(index).handle.is_valid()){ - libtorrent:size_type new_size = file_size; - std::pair list = std::make_pair(file_name, new_size); - std::vector > Vector; - Vector.push_back(list); + + std::vector > remap_vector; + + for (long i = 0; i < PyList_Size(file_path_object); i++) { + remap_vector.push_back(std::make_pair(PyString_AS_STRING(PyList_GetItem(file_path_object, i)), PyInt_AsLong(PyList_GetItem(file_size_object, i)))); + } torrent_info t = M_torrents->at(index).handle.get_torrent_info(); - bool ret = t.remap_files(Vector); + bool ret = t.remap_files(remap_vector); if (ret){ - printf("it worked!\n"); + printf("remap worked!\n"); } else{ - printf("it failed!\n"); + printf("remap failed!\n"); } } Py_INCREF(Py_None); return Py_None; diff --git a/src/interface.py b/src/interface.py index 5bdc10810..acf421ea0 100644 --- a/src/interface.py +++ b/src/interface.py @@ -176,9 +176,17 @@ class DelugeGTK: self.manager.unique_IDs[unique_ID].trackers) except: pass - except: - pass - except: + except AttributeError: + try: + if self.manager.unique_IDs[unique_ID].trackers: + try: + self.manager.replace_trackers(unique_ID, \ + self.manager.unique_IDs[unique_ID].trackers) + except: + pass + except AttributeError: + pass + except AttributeError: pass def connect_signals(self):