Skip to content

Commit 6dca8d2

Browse files
committed
Add always delete data feature
Adds a new feature to ruTorrent to replace the default "remove" option in the torrent menu to always delete torrent data. This feature is useful in situations like seed boxes to always remove torrent data, when deleting torrents from the web interface.
1 parent bf2eae1 commit 6dca8d2

3 files changed

Lines changed: 39 additions & 21 deletions

File tree

plugins/erasedata/conf.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
$enableForceDeletion = false;
66

77
$erasedebug_enabled = false;
8+
9+
// Replaces "remove" option in torrent menu to always delete with data
10+
// Refrains from showing other options on web interface
11+
$replaceRemoveTorrent = false;

plugins/erasedata/init.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,41 @@ if(plugin.canChangeMenu())
1414
theWebUI.perform( "removewithdata" );
1515
}
1616

17-
plugin.createMenu = theWebUI.createMenu;
18-
theWebUI.createMenu = function( e, id )
17+
if ( plugin.replaceRemoveTorrent )
1918
{
20-
plugin.createMenu.call(this, e, id);
21-
if(plugin.enabled)
22-
{
23-
var el = theContextMenu.get( theUILang.Remove );
24-
if( el )
25-
{
26-
var _c0 = [];
27-
_c0.push( [theUILang.Delete_data,
28-
(this.getTable("trt").selCount>1) ||
29-
this.isTorrentCommandEnabled("remove",id) ? "theWebUI.removeWithData(false)" : null] );
30-
if( plugin.enableForceDeletion )
31-
{
32-
_c0.push( [theUILang.Delete_data_with_path,
33-
(this.getTable("trt").selCount>1) ||
34-
this.isTorrentCommandEnabled("remove",id) ? "theWebUI.removeWithData(true)" : null] );
35-
}
36-
theContextMenu.add( el, [CMENU_CHILD, theUILang.Remove_and, _c0] );
37-
}
38-
}
19+
if (plugin.enabled)
20+
{
21+
theWebUI.remove = function()
22+
{
23+
theWebUI.removeWithData( plugin.enableForceDeletion );
24+
}
25+
}
26+
}
27+
else
28+
{
29+
plugin.createMenu = theWebUI.createMenu;
30+
theWebUI.createMenu = function( e, id )
31+
{
32+
plugin.createMenu.call(this, e, id);
33+
if(plugin.enabled)
34+
{
35+
var el = theContextMenu.get( theUILang.Remove );
36+
if( el )
37+
{
38+
var _c0 = [];
39+
_c0.push( [theUILang.Delete_data,
40+
(this.getTable("trt").selCount>1) ||
41+
this.isTorrentCommandEnabled("remove",id) ? "theWebUI.removeWithData(false)" : null] );
42+
if( plugin.enableForceDeletion )
43+
{
44+
_c0.push( [theUILang.Delete_data_with_path,
45+
(this.getTable("trt").selCount>1) ||
46+
this.isTorrentCommandEnabled("remove",id) ? "theWebUI.removeWithData(true)" : null] );
47+
}
48+
theContextMenu.add( el, [CMENU_CHILD, theUILang.Remove_and, _c0] );
49+
}
50+
}
51+
}
3952
}
4053

4154
rTorrentStub.prototype.removewithdata = function()

plugins/erasedata/init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
{
2828
$theSettings->registerPlugin($plugin["name"],$pInfo["perms"]);
2929
$jResult.="plugin.enableForceDeletion = ".($enableForceDeletion ? 1 : 0).";";
30+
$jResult.="plugin.replaceRemoveTorrent = ".($replaceRemoveTorrent ? 1 : 0).";";
3031
}
3132
else
3233
$jResult.="plugin.disable(); noty('erasedata: '+theUILang.pluginCantStart,'error');";

0 commit comments

Comments
 (0)