sharing/csv: honor stock encoding
This commit is contained in:
@@ -138,6 +138,7 @@ class BaseSharing(ApplicationBase):
|
||||
_rights: rights.BaseRights
|
||||
_auth_delay: float
|
||||
_enabled: bool = False
|
||||
_encoding: str
|
||||
default_permissions_create_token: str
|
||||
default_permissions_create_map: str
|
||||
sharing_db_type: str
|
||||
@@ -154,6 +155,7 @@ class BaseSharing(ApplicationBase):
|
||||
self._rights = rights.load(configuration)
|
||||
self._storage = storage.load(configuration)
|
||||
self._auth_delay = configuration.get("auth", "delay")
|
||||
self._encoding = configuration.get("encoding", "stock")
|
||||
self._validate_user_value = configuration.get("server", "validate_user_value")
|
||||
self._validate_path_value = configuration.get("server", "validate_path_value")
|
||||
# Sharing
|
||||
|
||||
@@ -400,7 +400,7 @@ class Sharing(sharing.BaseSharing):
|
||||
logger.debug("sharing database load begin: %r", file)
|
||||
self._sharing_cache = []
|
||||
with self._storage.acquire_lock("r", None):
|
||||
with open(file, 'r', newline='') as csvfile:
|
||||
with open(file, 'r', newline='', encoding=self._encoding) as csvfile:
|
||||
reader = csv.DictReader(csvfile, fieldnames=sharing.DB_FIELDS_V1, delimiter=';')
|
||||
self._lines = 0
|
||||
for row in reader:
|
||||
@@ -453,7 +453,7 @@ class Sharing(sharing.BaseSharing):
|
||||
return True
|
||||
|
||||
def _write_csv(self, file: str) -> bool:
|
||||
with open(file, 'w', newline='') as csvfile:
|
||||
with open(file, 'w', newline='', encoding=self._encoding) as csvfile:
|
||||
writer = csv.DictWriter(csvfile, fieldnames=sharing.DB_FIELDS_V1, delimiter=';')
|
||||
writer.writerows(self._sharing_cache)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user