diff --git a/deluge/ui/console/commands/add.py b/deluge/ui/console/commands/add.py
index 7878438..6583d6f 100644
a
|
b
|
|
42 | 42 | |
43 | 43 | from optparse import make_option |
44 | 44 | import os |
45 | | import base64 |
| 45 | import base6 |
| 46 | import gio |
46 | 47 | |
47 | 48 | class Command(BaseCommand): |
48 | 49 | """Add a torrent""" |
… |
… |
def handle(self, *args, **options):
|
63 | 64 | # Keep a list of deferreds to make a DeferredList |
64 | 65 | deferreds = [] |
65 | 66 | for arg in args: |
66 | | if not os.path.exists(arg): |
| 67 | filename = os.path.split(arg)[-1] |
| 68 | gfile = gio.File(arg) |
| 69 | |
| 70 | if not gfile.query_exists(): |
67 | 71 | self.console.write("{!error!}%s doesn't exist!" % arg) |
68 | 72 | continue |
69 | | if not os.path.isfile(arg): |
| 73 | if gfile.query_file_type(gio.FILE_QUERY_INFO_NONE) is gio.FILE_TYPE_DIRECTORY: |
70 | 74 | self.console.write("{!error!}This is a directory!") |
71 | 75 | continue |
72 | | self.console.write("{!info!}Attempting to add torrent: %s" % arg) |
73 | | filename = os.path.split(arg)[-1] |
74 | | filedump = base64.encodestring(open(arg, "rb").read()) |
| 76 | self.console.write("{!info!}Attempting to add torrent: %s" % arg |
| 77 | |
| 78 | try: |
| 79 | stream = gfile.read() |
| 80 | except gio.Error: |
| 81 | self.console.write("{!error!}Torrent was not added! Error while reading stream.") |
| 82 | else: |
| 83 | filedump = base64.encodestring(stream.read()) |
| 84 | finally: |
| 85 | stream.close()) |
75 | 86 | |
76 | 87 | def on_success(result): |
77 | 88 | self.console.write("{!success!}Torrent added!") |