Функция localize_path
parent
7e8efc570e
commit
1e22099b28
|
@ -28,7 +28,7 @@ import BaseHTTPServer
|
||||||
import SocketServer
|
import SocketServer
|
||||||
import threading
|
import threading
|
||||||
import io
|
import io
|
||||||
import socket
|
from util import localize_path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,10 +377,7 @@ class TorrentFS(object):
|
||||||
raise IndexError
|
raise IndexError
|
||||||
fileEntry = info.file_at(index)
|
fileEntry = info.file_at(index)
|
||||||
fe_path = fileEntry.path
|
fe_path = fileEntry.path
|
||||||
fe_path = fe_path.decode(chardet.detect(fe_path)['encoding'])
|
path = os.path.abspath(os.path.join(self.SavePath(), localize_path(fe_path)))
|
||||||
if not sys.platform.startswith('win'):
|
|
||||||
fe_path = fe_path.encode(sys.getfilesystemencoding())
|
|
||||||
path = os.path.abspath(os.path.join(self.SavePath(), fe_path))
|
|
||||||
return TorrentFile(
|
return TorrentFile(
|
||||||
self,
|
self,
|
||||||
fileEntry,
|
fileEntry,
|
||||||
|
@ -388,10 +385,7 @@ class TorrentFS(object):
|
||||||
index
|
index
|
||||||
)
|
)
|
||||||
def FileByName(self, name):
|
def FileByName(self, name):
|
||||||
name = name.decode(chardet.detect(name)['encoding'])
|
savePath = os.path.abspath(os.path.join(self.SavePath(), localize_path(name)))
|
||||||
if not sys.platform.startswith('win'):
|
|
||||||
name = name.encode(sys.getfilesystemencoding())
|
|
||||||
savePath = os.path.abspath(os.path.join(self.SavePath(), name))
|
|
||||||
for file_ in self.Files():
|
for file_ in self.Files():
|
||||||
if file_.savePath == savePath:
|
if file_.savePath == savePath:
|
||||||
return file_
|
return file_
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
|
import chardet
|
||||||
|
|
||||||
|
|
||||||
|
def localize_path(path):
|
||||||
|
path = path.decode(chardet.detect(path)['encoding'])
|
||||||
|
if not sys.platform.startswith('win'):
|
||||||
|
path = path.encode(sys.getfilesystemencoding())
|
||||||
|
return path
|
||||||
|
|
||||||
def can_bind(host, port):
|
def can_bind(host, port):
|
||||||
"""
|
"""
|
||||||
Checks we can bind to specified host and port
|
Checks we can bind to specified host and port
|
||||||
|
|
Loading…
Reference in New Issue