mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 23:18:40 +00:00
Handle torrent add failures in web UI
Show an error dialog and remove the torrent from the list when a torrent file fails to upload or a URL fails to download.
This commit is contained in:
parent
2e0b0d9474
commit
ce4b4ef48e
6 changed files with 129 additions and 63 deletions
|
@ -1429,7 +1429,8 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
|
||||||
Deluge.add.Window.superclass.initComponent.call(this);
|
Deluge.add.Window.superclass.initComponent.call(this);
|
||||||
this.addEvents(
|
this.addEvents(
|
||||||
'beforeadd',
|
'beforeadd',
|
||||||
'add'
|
'add',
|
||||||
|
'addfailed'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1628,12 +1629,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
||||||
this.url = new Deluge.add.UrlWindow();
|
this.url = new Deluge.add.UrlWindow();
|
||||||
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.url.on('add', this.onTorrentAdd, this);
|
this.url.on('add', this.onTorrentAdd, this);
|
||||||
|
this.url.on('addfailed', this.onTorrentAddFailed, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.file) {
|
if (!this.file) {
|
||||||
this.file = new Deluge.add.FileWindow();
|
this.file = new Deluge.add.FileWindow();
|
||||||
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.file.on('add', this.onTorrentAdd, this);
|
this.file.on('add', this.onTorrentAdd, this);
|
||||||
|
this.file.on('addfailed', this.onTorrentAddFailed, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.optionsPanel.form.getDefaults();
|
this.optionsPanel.form.getDefaults();
|
||||||
|
@ -1665,6 +1668,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onTorrentAddFailed: function(torrentId) {
|
||||||
|
var store = this.list.getStore();
|
||||||
|
var torrentRecord = store.getById(torrentId);
|
||||||
|
if (torrentRecord) {
|
||||||
|
store.remove(torrentRecord);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onUrl: function(button, event) {
|
onUrl: function(button, event) {
|
||||||
this.url.show();
|
this.url.show();
|
||||||
}
|
}
|
||||||
|
@ -1770,6 +1781,15 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
|
||||||
// private
|
// private
|
||||||
onUploadFailure: function(form, action) {
|
onUploadFailure: function(form, action) {
|
||||||
this.hide();
|
this.hide();
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('Error'),
|
||||||
|
msg: _('Failed to upload torrent'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
this.fireEvent('addfailed', this.torrentId);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
|
@ -2369,7 +2389,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
|
||||||
var cookies = this.cookieField.getValue();
|
var cookies = this.cookieField.getValue();
|
||||||
var torrentId = this.createTorrentId();
|
var torrentId = this.createTorrentId();
|
||||||
|
|
||||||
if (url.substring(0,20) == 'magnet:?xt=urn:btih:') {
|
if (url.indexOf('magnet:?') == 0 && url.indexOf('xt=urn:btih') > -1) {
|
||||||
deluge.client.web.get_magnet_info(url, {
|
deluge.client.web.get_magnet_info(url, {
|
||||||
success: this.onGotInfo,
|
success: this.onGotInfo,
|
||||||
scope: this,
|
scope: this,
|
||||||
|
@ -2379,6 +2399,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
|
||||||
} else {
|
} else {
|
||||||
deluge.client.web.download_torrent_from_url(url, cookies, {
|
deluge.client.web.download_torrent_from_url(url, cookies, {
|
||||||
success: this.onDownload,
|
success: this.onDownload,
|
||||||
|
failure: this.onDownloadFailed,
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
});
|
});
|
||||||
|
@ -2398,6 +2419,18 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDownloadFailed: function(obj, resp, req) {
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('Error'),
|
||||||
|
msg: _('Failed to download torrent'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
this.fireEvent('addfailed', req.options.torrentId);
|
||||||
|
},
|
||||||
|
|
||||||
onGotInfo: function(info, obj, response, request) {
|
onGotInfo: function(info, obj, response, request) {
|
||||||
info['filename'] = request.options.filename;
|
info['filename'] = request.options.filename;
|
||||||
this.fireEvent('add', request.options.torrentId, info);
|
this.fireEvent('add', request.options.torrentId, info);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -186,12 +186,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
||||||
this.url = new Deluge.add.UrlWindow();
|
this.url = new Deluge.add.UrlWindow();
|
||||||
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.url.on('add', this.onTorrentAdd, this);
|
this.url.on('add', this.onTorrentAdd, this);
|
||||||
|
this.url.on('addfailed', this.onTorrentAddFailed, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.file) {
|
if (!this.file) {
|
||||||
this.file = new Deluge.add.FileWindow();
|
this.file = new Deluge.add.FileWindow();
|
||||||
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
this.file.on('add', this.onTorrentAdd, this);
|
this.file.on('add', this.onTorrentAdd, this);
|
||||||
|
this.file.on('addfailed', this.onTorrentAddFailed, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.optionsPanel.form.getDefaults();
|
this.optionsPanel.form.getDefaults();
|
||||||
|
@ -223,6 +225,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onTorrentAddFailed: function(torrentId) {
|
||||||
|
var store = this.list.getStore();
|
||||||
|
var torrentRecord = store.getById(torrentId);
|
||||||
|
if (torrentRecord) {
|
||||||
|
store.remove(torrentRecord);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onUrl: function(button, event) {
|
onUrl: function(button, event) {
|
||||||
this.url.show();
|
this.url.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,15 @@ Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
|
||||||
// private
|
// private
|
||||||
onUploadFailure: function(form, action) {
|
onUploadFailure: function(form, action) {
|
||||||
this.hide();
|
this.hide();
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('Error'),
|
||||||
|
msg: _('Failed to upload torrent'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
this.fireEvent('addfailed', this.torrentId);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
|
|
|
@ -91,6 +91,7 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
|
||||||
} else {
|
} else {
|
||||||
deluge.client.web.download_torrent_from_url(url, cookies, {
|
deluge.client.web.download_torrent_from_url(url, cookies, {
|
||||||
success: this.onDownload,
|
success: this.onDownload,
|
||||||
|
failure: this.onDownloadFailed,
|
||||||
scope: this,
|
scope: this,
|
||||||
torrentId: torrentId
|
torrentId: torrentId
|
||||||
});
|
});
|
||||||
|
@ -110,6 +111,18 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDownloadFailed: function(obj, resp, req) {
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('Error'),
|
||||||
|
msg: _('Failed to download torrent'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
this.fireEvent('addfailed', req.options.torrentId);
|
||||||
|
},
|
||||||
|
|
||||||
onGotInfo: function(info, obj, response, request) {
|
onGotInfo: function(info, obj, response, request) {
|
||||||
info['filename'] = request.options.filename;
|
info['filename'] = request.options.filename;
|
||||||
this.fireEvent('add', request.options.torrentId, info);
|
this.fireEvent('add', request.options.torrentId, info);
|
||||||
|
|
|
@ -41,7 +41,8 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
|
||||||
Deluge.add.Window.superclass.initComponent.call(this);
|
Deluge.add.Window.superclass.initComponent.call(this);
|
||||||
this.addEvents(
|
this.addEvents(
|
||||||
'beforeadd',
|
'beforeadd',
|
||||||
'add'
|
'add',
|
||||||
|
'addfailed'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue