remap files update
This commit is contained in:
parent
b764486bff
commit
7e175dd4c0
|
@ -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()
|
||||
|
|
|
@ -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<std::string, libtorrent::size_type> list = std::make_pair(file_name, new_size);
|
||||
std::vector<std::pair<std::string, libtorrent::size_type> > Vector;
|
||||
Vector.push_back(list);
|
||||
|
||||
std::vector<std::pair<std::string, libtorrent::size_type> > 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;
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue