Author: damoxc
Revision: 4997
Log:
handle an invalid torrent file and show an error message box
Diff:
Modified: trunk/deluge/ui/web/js/deluge-add.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-add.js 2009-04-02 19:40:41 UTC (rev
4996)
+++ trunk/deluge/ui/web/js/deluge-add.js 2009-04-02 19:43:08 UTC (rev
4997)
@@ -98,6 +98,17 @@
},
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.torrents[info['info_hash']] = info;
},
@@ -226,15 +237,10 @@
onUploadSuccess: function(fp, upload) {
this.Window.hide();
var filename = upload.result.toString();
+ this.form.items.get('torrentFile').setValue('');
Deluge.Client.web.get_torrent_info(filename, {
- onSuccess: this.onGotInfo.bindWithEvent(this)
+ onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(this)
});
- },
-
- onGotInfo: function(info) {
- var bound = Deluge.Add.onTorrentAdded.bind(Deluge.Add)
- this.form.items.get('torrentFile').setValue('');
- bound(info);
}
}
@@ -289,15 +295,10 @@
},
onDownload: function(filename) {
+ this.form.items.get('url').setValue('');
Deluge.Client.web.get_torrent_info(filename, {
- onSuccess: this.onGotInfo.bindWithEvent(this)
+ onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(this)
});
- },
-
- onGotInfo: function(info) {
- var bound = Deluge.Add.onTorrentAdded.bind(Deluge.Add)
- this.form.items.get('url').setValue('');
- bound(info);
}
}
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-04-02 19:40:41 UTC (rev 4996)
+++ trunk/deluge/ui/web/json_api.py 2009-04-02 19:43:08 UTC (rev 4997)
@@ -396,7 +396,10 @@
}
"""
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
@export
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---