Erik Svensson avatar Erik Svensson committed 6448871

Added ValueError exception when having path delimiter in the name argument in Client.rename_torrent.path.

Comments (0)

Files changed (2)

transmissionrpc/client.py

 # Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
 # Licensed under the MIT license.
 
-import re, time, operator, warnings
+import re, time, operator, warnings, os
 import base64
 import json
 
         warnings.warn('locate has been deprecated, please use locate_torrent_data instead.', DeprecationWarning)
         self.locate_torrent_data(ids, location, timeout)
 
-    def rename_torrent_path(self, torrent_id, location, destination, timeout=None):
+    def rename_torrent_path(self, torrent_id, location, name, timeout=None):
         """
         Rename directory and/or files for torrent.
         Remember to use get_torrent or get_torrents to update your file information.
         torrent_id = parse_torrent_id(torrent_id)
         if torrent_id is None:
             raise ValueError("Invalid id")
-        args = {'path': location, 'name': destination}
+        dirname = os.path.dirname(name)
+        if len(dirname) > 0:
+            raise ValueError("Target name cannot contain a path delimiter")
+        args = {'path': location, 'name': name}
         result = self._request('torrent-rename-path', args, torrent_id, True, timeout=timeout)
         return (result['path'], result['name'])
 

transmissionrpc/utils.py

     levels = {'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR}
 
     trpc_logger = logging.getLogger('transmissionrpc')
-    loghandler = logging.FileHandler(filepath)
+    loghandler = logging.FileHandler(filepath, encoding='utf-8')
     if level in list(levels.keys()):
         loglevel = levels[level]
         trpc_logger.setLevel(loglevel)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.