]> git.phdru.name Git - extfs.d.git/blobdiff - torrent
Feat(torrent): Improve error messages
[extfs.d.git] / torrent
diff --git a/torrent b/torrent
index 550ad72ebf9c1f459e12a5cfa7b0eccf19bb2207..7caff9b497f40b3f0374e2d1517e0389d9ae5fdc 100755 (executable)
--- a/torrent
+++ b/torrent
@@ -56,7 +56,10 @@ except ImportError:
 if use_locale:
     # Get the default charset.
     try:
-        lcAll = locale.getdefaultlocale()
+        if sys.version_info[:2] < (3, 11):
+            lcAll = locale.getdefaultlocale()
+        else:
+            lcAll = []
     except locale.Error as err:
         #print("WARNING:", err, file=sys.stderr)
         lcAll = []
@@ -123,8 +126,7 @@ def mctorrent_list():
                 if name_utf8:
                     path = '/'.join([name_utf8] + file['path.utf-8'])
                 else:
-                    _name_utf8 = name
-                    path = '/'.join([_name_utf8] + file['path.utf-8'])
+                    path = '/'.join([name] + file['path.utf-8'])
             else:
                 if name_utf8:
                     path = '/'.join([name_utf8] + path)
@@ -216,15 +218,13 @@ def mctorrent_copyout():
             break
 
     if torrent_filename in ('.META/private', '.META/piece length'):
-        if 'info' not in torrent:
-            torrent_error('Info absent')
         info = torrent['info']
         if torrent_filename == '.META/private':
             if 'private' not in info:
-                torrent_error('Info absent')
+                torrent_error('Private absent')
         if torrent_filename == '.META/piece length':
             if 'piece length' not in info:
-                torrent_error('Info absent')
+                torrent_error('Piece length absent')
         data = str(info[torrent_filename[len('.META/'):]])
 
     if not torrent_filename.startswith('.META/'):
@@ -240,7 +240,8 @@ def mctorrent_copyout():
 
 def mctorrent_copyin():
     """Put a file to the VFS"""
-    sys.exit("Torrent VFS doesn't support adding files (read-only filesystem)")
+    sys.exit("Torrent VFS doesn't support adding/overwriting files "
+             "(read-only filesystem)")
 
 
 def mctorrent_rm():