mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
handle an invalid torrent file and show an error message box
This commit is contained in:
parent
b1c992da61
commit
031ec92799
2 changed files with 21 additions and 17 deletions
|
@ -98,6 +98,17 @@ Deluge.Add = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onTorrentAdded: function(info) {
|
onTorrentAdded: function(info) {
|
||||||
|
if (!info) {
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: _('Error'),
|
||||||
|
msg: _('Not a valid torrent'),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.Store.loadData([[info['info_hash'], info['name']]], true);
|
this.Store.loadData([[info['info_hash'], info['name']]], true);
|
||||||
this.torrents[info['info_hash']] = info;
|
this.torrents[info['info_hash']] = info;
|
||||||
},
|
},
|
||||||
|
@ -226,15 +237,10 @@ Deluge.Add.File = {
|
||||||
onUploadSuccess: function(fp, upload) {
|
onUploadSuccess: function(fp, upload) {
|
||||||
this.Window.hide();
|
this.Window.hide();
|
||||||
var filename = upload.result.toString();
|
var filename = upload.result.toString();
|
||||||
Deluge.Client.web.get_torrent_info(filename, {
|
|
||||||
onSuccess: this.onGotInfo.bindWithEvent(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onGotInfo: function(info) {
|
|
||||||
var bound = Deluge.Add.onTorrentAdded.bind(Deluge.Add)
|
|
||||||
this.form.items.get('torrentFile').setValue('');
|
this.form.items.get('torrentFile').setValue('');
|
||||||
bound(info);
|
Deluge.Client.web.get_torrent_info(filename, {
|
||||||
|
onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(this)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,15 +295,10 @@ Deluge.Add.Url = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onDownload: function(filename) {
|
onDownload: function(filename) {
|
||||||
Deluge.Client.web.get_torrent_info(filename, {
|
|
||||||
onSuccess: this.onGotInfo.bindWithEvent(this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onGotInfo: function(info) {
|
|
||||||
var bound = Deluge.Add.onTorrentAdded.bind(Deluge.Add)
|
|
||||||
this.form.items.get('url').setValue('');
|
this.form.items.get('url').setValue('');
|
||||||
bound(info);
|
Deluge.Client.web.get_torrent_info(filename, {
|
||||||
|
onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(this)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,10 @@ class WebApi(JSONComponent):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
d = Deferred()
|
d = Deferred()
|
||||||
d.callback(uicommon.get_torrent_info(filename.strip()))
|
try:
|
||||||
|
d.callback(uicommon.get_torrent_info(filename.strip()))
|
||||||
|
except:
|
||||||
|
d.callback(False)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export
|
@export
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue