mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-26 10:05:19 +00:00
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]
|
selected_paths = self.file_view.get_selection().get_selected_rows()[1]
|
||||||
try:
|
try:
|
||||||
for path in selected_paths:
|
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)
|
convert_path_to_child_path(path)
|
||||||
file_name = self.file_store.get_value(
|
self.file_name = self.file_store.get_value(
|
||||||
self.file_store.get_iter(child_path), 0)
|
self.file_store.get_iter(self.child_path), 0)
|
||||||
file_size = self.file_store.get_value(
|
self.file_size = self.file_store.get_value(
|
||||||
self.file_store.get_iter(child_path), 1)
|
self.file_store.get_iter(self.child_path), 1)
|
||||||
entry.set_text(file_name)
|
|
||||||
|
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()
|
gtk.gdk.threads_enter()
|
||||||
dlg.show_all()
|
dlg.show_all()
|
||||||
response = dlg.run()
|
response = dlg.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
new_name = entry.get_text().decode("utf_8")
|
new_name = entry.get_text().decode("utf_8")
|
||||||
dlg.destroy()
|
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:
|
else:
|
||||||
dlg.destroy()
|
dlg.destroy()
|
||||||
gtk.gdk.threads_leave()
|
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)
|
static PyObject *torrent_remap_files(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
python_long unique_ID;
|
python_long unique_ID;
|
||||||
const char *file_name;
|
PyObject *file_path_object;
|
||||||
float file_size;
|
PyObject *file_size_object;
|
||||||
if (!PyArg_ParseTuple(args, "isf", &unique_ID, &file_name, &file_size))
|
|
||||||
|
if (!PyArg_ParseTuple(args, "iOO", &unique_ID, &file_path_object, &file_size_object))
|
||||||
return NULL;
|
return NULL;
|
||||||
long index = get_index_from_unique_ID(unique_ID);
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (M_torrents->at(index).handle.is_valid()){
|
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> > remap_vector;
|
||||||
std::vector<std::pair<std::string, libtorrent::size_type> > Vector;
|
|
||||||
Vector.push_back(list);
|
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();
|
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){
|
if (ret){
|
||||||
printf("it worked!\n");
|
printf("remap worked!\n");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf("it failed!\n");
|
printf("remap failed!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_INCREF(Py_None); return Py_None;
|
Py_INCREF(Py_None); return Py_None;
|
||||||
|
@ -176,9 +176,17 @@ class DelugeGTK:
|
|||||||
self.manager.unique_IDs[unique_ID].trackers)
|
self.manager.unique_IDs[unique_ID].trackers)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
except:
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user