mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 20:14:13 +00:00
[#2250] [WebUI] [Console] Use new core.remove_torrents method
This commit is contained in:
parent
08363f28dd
commit
faf3f96322
@ -34,8 +34,14 @@ class Command(BaseCommand):
|
|||||||
for arg in args:
|
for arg in args:
|
||||||
torrent_ids.extend(self.console.match_torrent(arg))
|
torrent_ids.extend(self.console.match_torrent(arg))
|
||||||
|
|
||||||
for torrent_id in torrent_ids:
|
def on_removed_finished(errors):
|
||||||
client.core.remove_torrent(torrent_id, options["remove_data"])
|
if errors:
|
||||||
|
self.console.write("Error(s) occured when trying to delete torrent(s).")
|
||||||
|
for t_id, e_msg in errors:
|
||||||
|
self.console.write("Error removing torrent %s : %s" % (t_id, e_msg))
|
||||||
|
|
||||||
|
d = client.core.remove_torrents(torrent_ids, options["remove_data"])
|
||||||
|
d.addCallback(on_removed_finished)
|
||||||
|
|
||||||
def complete(self, line):
|
def complete(self, line):
|
||||||
# We use the ConsoleUI torrent tab complete method
|
# We use the ConsoleUI torrent tab complete method
|
||||||
|
@ -146,10 +146,18 @@ def torrent_action(idx, data, mode, ids):
|
|||||||
return
|
return
|
||||||
mode.clear_marks()
|
mode.clear_marks()
|
||||||
|
|
||||||
wd = data["remove_files"]
|
remove_data = data["remove_files"]
|
||||||
for tid in ids:
|
|
||||||
log.debug("Removing torrent: %s, %d", tid, wd)
|
def on_removed_finished(errors):
|
||||||
client.core.remove_torrent(tid, wd).addErrback(action_error, mode)
|
if errors:
|
||||||
|
error_msgs = ""
|
||||||
|
for t_id, e_msg in errors:
|
||||||
|
error_msgs += "Error removing torrent %s : %s\n" % (t_id, e_msg)
|
||||||
|
mode.report_message("Error(s) occured when trying to delete torrent(s).", error_msgs)
|
||||||
|
mode.refresh()
|
||||||
|
|
||||||
|
d = client.core.remove_torrents(ids, remove_data)
|
||||||
|
d.addCallback(on_removed_finished)
|
||||||
|
|
||||||
def got_status(status):
|
def got_status(status):
|
||||||
return (status["name"], status["state"])
|
return (status["name"], status["state"])
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*!
|
/*!
|
||||||
* Deluge.RemoveWindow.js
|
* Deluge.RemoveWindow.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -35,61 +35,61 @@
|
|||||||
* @extends Ext.Window
|
* @extends Ext.Window
|
||||||
*/
|
*/
|
||||||
Deluge.RemoveWindow = Ext.extend(Ext.Window, {
|
Deluge.RemoveWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
title: _('Remove Torrent'),
|
title: _('Remove Torrent'),
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
width: 350,
|
width: 350,
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|
||||||
buttonAlign: 'right',
|
buttonAlign: 'right',
|
||||||
closeAction: 'hide',
|
closeAction: 'hide',
|
||||||
closable: true,
|
closable: true,
|
||||||
iconCls: 'x-deluge-remove-window-icon',
|
iconCls: 'x-deluge-remove-window-icon',
|
||||||
plain: true,
|
plain: true,
|
||||||
|
|
||||||
bodyStyle: 'padding: 5px; padding-left: 10px;',
|
bodyStyle: 'padding: 5px; padding-left: 10px;',
|
||||||
html: 'Are you sure you wish to remove the torrent (s)?',
|
html: 'Are you sure you wish to remove the torrent (s)?',
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.RemoveWindow.superclass.initComponent.call(this);
|
Deluge.RemoveWindow.superclass.initComponent.call(this);
|
||||||
this.addButton(_('Cancel'), this.onCancel, this);
|
this.addButton(_('Cancel'), this.onCancel, this);
|
||||||
this.addButton(_('Remove With Data'), this.onRemoveData, this);
|
this.addButton(_('Remove With Data'), this.onRemoveData, this);
|
||||||
this.addButton(_('Remove Torrent'), this.onRemove, this);
|
this.addButton(_('Remove Torrent'), this.onRemove, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function(removeData) {
|
remove: function(removeData) {
|
||||||
Ext.each(this.torrentIds, function(torrentId) {
|
deluge.client.core.remove_torrents(this.torrentIds, removeData, {
|
||||||
deluge.client.core.remove_torrent(torrentId, removeData, {
|
success: function(result) {
|
||||||
success: function() {
|
if (result) {
|
||||||
this.onRemoved(torrentId);
|
console.log("Error(s) occured when trying to delete torrent(s).");
|
||||||
},
|
}
|
||||||
scope: this,
|
this.onRemoved(this.torrentIds);
|
||||||
torrentId: torrentId
|
},
|
||||||
});
|
scope: this,
|
||||||
}, this);
|
torrentIds: this.torrentIds
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(ids) {
|
show: function(ids) {
|
||||||
Deluge.RemoveWindow.superclass.show.call(this);
|
Deluge.RemoveWindow.superclass.show.call(this);
|
||||||
this.torrentIds = ids;
|
this.torrentIds = ids;
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancel: function() {
|
onCancel: function() {
|
||||||
this.hide();
|
this.hide();
|
||||||
this.torrentIds = null;
|
this.torrentIds = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
this.remove(false);
|
this.remove(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoveData: function() {
|
onRemoveData: function() {
|
||||||
this.remove(true);
|
this.remove(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemoved: function(torrentId) {
|
onRemoved: function(torrentIds) {
|
||||||
deluge.events.fire('torrentRemoved', torrentId);
|
deluge.events.fire('torrentsRemoved', torrentIds);
|
||||||
this.hide();
|
this.hide();
|
||||||
deluge.ui.update();
|
deluge.ui.update();
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@
|
|||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Deluge.TorrentGrid.superclass.initComponent.call(this);
|
Deluge.TorrentGrid.superclass.initComponent.call(this);
|
||||||
deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
|
deluge.events.on('torrentsRemoved', this.onTorrentsRemoved, this);
|
||||||
deluge.events.on('disconnect', this.onDisconnect, this);
|
deluge.events.on('disconnect', this.onDisconnect, this);
|
||||||
|
|
||||||
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
||||||
@ -459,7 +459,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onTorrentRemoved: function(torrentIds) {
|
onTorrentsRemoved: function(torrentIds) {
|
||||||
var selModel = this.getSelectionModel();
|
var selModel = this.getSelectionModel();
|
||||||
Ext.each(torrentIds, function(torrentId) {
|
Ext.each(torrentIds, function(torrentId) {
|
||||||
var record = this.getStore().getById(torrentId);
|
var record = this.getStore().getById(torrentId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user