mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-13 04:54:23 +00:00
Fix #1373 use of cyrllic paths
This commit is contained in:
parent
2a3eb0578c
commit
6d2a001635
@ -475,7 +475,7 @@ def free_space(path):
|
|||||||
sectors, bytes, free, total = map(long, win32file.GetDiskFreeSpace(path))
|
sectors, bytes, free, total = map(long, win32file.GetDiskFreeSpace(path))
|
||||||
return (free * sectors * bytes)
|
return (free * sectors * bytes)
|
||||||
else:
|
else:
|
||||||
disk_data = os.statvfs(path)
|
disk_data = os.statvfs(path.encode("utf8"))
|
||||||
block_size = disk_data.f_bsize
|
block_size = disk_data.f_bsize
|
||||||
return disk_data.f_bavail * block_size
|
return disk_data.f_bavail * block_size
|
||||||
|
|
||||||
|
@ -191,6 +191,7 @@ what is currently in the config and it could not convert the value
|
|||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
value = deluge.common.utf8_encoded(value)
|
value = deluge.common.utf8_encoded(value)
|
||||||
|
|
||||||
|
|
||||||
if not self.__config.has_key(key):
|
if not self.__config.has_key(key):
|
||||||
self.__config[key] = value
|
self.__config[key] = value
|
||||||
log.debug("Setting '%s' to %s of %s", key, value, type(value))
|
log.debug("Setting '%s' to %s of %s", key, value, type(value))
|
||||||
@ -204,7 +205,10 @@ what is currently in the config and it could not convert the value
|
|||||||
|
|
||||||
if value is not None and oldtype != type(None) and oldtype != newtype:
|
if value is not None and oldtype != type(None) and oldtype != newtype:
|
||||||
try:
|
try:
|
||||||
value = oldtype(value)
|
if oldtype == unicode:
|
||||||
|
value = oldtype(value, "utf8")
|
||||||
|
else:
|
||||||
|
value = oldtype(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
log.warning("Type '%s' invalid for '%s'", newtype, key)
|
log.warning("Type '%s' invalid for '%s'", newtype, key)
|
||||||
raise
|
raise
|
||||||
@ -254,7 +258,10 @@ what is currently in the config and it could not convert the value
|
|||||||
5
|
5
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.__config[key]
|
if isinstance(self.__config[key], str):
|
||||||
|
return self.__config[key].decode("utf8")
|
||||||
|
else:
|
||||||
|
return self.__config[key]
|
||||||
|
|
||||||
def register_change_callback(self, callback):
|
def register_change_callback(self, callback):
|
||||||
"""
|
"""
|
||||||
@ -404,7 +411,7 @@ what is currently in the config and it could not convert the value
|
|||||||
# The config has not changed so lets just return
|
# The config has not changed so lets just return
|
||||||
if self._save_timer and self._save_timer.active():
|
if self._save_timer and self._save_timer.active():
|
||||||
self._save_timer.cancel()
|
self._save_timer.cancel()
|
||||||
return
|
return True
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
log.warning("Unable to open config file: %s because: %s", filename, e)
|
log.warning("Unable to open config file: %s because: %s", filename, e)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
|
|
||||||
@ -6,7 +8,7 @@ import os
|
|||||||
|
|
||||||
from deluge.config import Config
|
from deluge.config import Config
|
||||||
|
|
||||||
DEFAULTS = {"string": "foobar", "int": 1, "float": 0.435, "bool": True}
|
DEFAULTS = {"string": "foobar", "int": 1, "float": 0.435, "bool": True, "unicode": u"foobar"}
|
||||||
|
|
||||||
class ConfigTestCase(unittest.TestCase):
|
class ConfigTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -27,6 +29,9 @@ class ConfigTestCase(unittest.TestCase):
|
|||||||
config["foo"] = 2
|
config["foo"] = 2
|
||||||
self.assertEquals(config.get_item("foo"), 2)
|
self.assertEquals(config.get_item("foo"), 2)
|
||||||
|
|
||||||
|
config["unicode"] = u"ВИДЕОФИЛЬМЫ"
|
||||||
|
self.assertEquals(config["unicode"], u"ВИДЕОФИЛЬМЫ")
|
||||||
|
|
||||||
config._save_timer.cancel()
|
config._save_timer.cancel()
|
||||||
|
|
||||||
def test_load(self):
|
def test_load(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user