test and display features of used collection base directory
This commit is contained in:
@@ -407,7 +407,7 @@ def path_supports_symlink(path):
|
|||||||
|
|
||||||
|
|
||||||
def path_is_collision_free_case_sensitive(path):
|
def path_is_collision_free_case_sensitive(path):
|
||||||
# Test: case sensitive
|
"""Check whether path supports case sensitive entries."""
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
raise ValueError("%r is not a path" % (path))
|
raise ValueError("%r is not a path" % (path))
|
||||||
base_dir = tempfile.mkdtemp(dir=path)
|
base_dir = tempfile.mkdtemp(dir=path)
|
||||||
@@ -452,3 +452,76 @@ def path_is_collision_free_no_short_filename(path):
|
|||||||
os.rmdir(base_dir)
|
os.rmdir(base_dir)
|
||||||
logger.debug("path_is_collision_free (no short-filename): path=%r result=%s", path, result)
|
logger.debug("path_is_collision_free (no short-filename): path=%r result=%s", path, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def path_supports_unicode(path):
|
||||||
|
"""Check whether path supports unicode."""
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
raise ValueError("%r is not a path" % (path))
|
||||||
|
base_dir = tempfile.mkdtemp(dir=path)
|
||||||
|
part = "TEST😀"
|
||||||
|
test_dir = os.path.join(base_dir, part)
|
||||||
|
result = True
|
||||||
|
try:
|
||||||
|
os.mkdir(test_dir)
|
||||||
|
except OSError:
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
with os.scandir(base_dir) as entries:
|
||||||
|
if part not in (e.name for e in entries):
|
||||||
|
result = False
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(test_dir)
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(base_dir)
|
||||||
|
logger.debug("path_supports_unicode: path=%r result=%s", path, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def path_supports_trailing_whitespace(path):
|
||||||
|
"""Check whether path supports trailing whitespace."""
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
raise ValueError("%r is not a path" % (path))
|
||||||
|
base_dir = tempfile.mkdtemp(dir=path)
|
||||||
|
part = "TEST "
|
||||||
|
test_dir = os.path.join(base_dir, part)
|
||||||
|
result = True
|
||||||
|
try:
|
||||||
|
os.mkdir(test_dir)
|
||||||
|
except OSError:
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
with os.scandir(base_dir) as entries:
|
||||||
|
if part not in (e.name for e in entries):
|
||||||
|
result = False
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(test_dir)
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(base_dir)
|
||||||
|
logger.debug("path_supports_trailing_whitespace: path=%r result=%s", path, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def path_supports_problematic_chars(path):
|
||||||
|
"""Check whether path supports problematic chars."""
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
raise ValueError("%r is not a path" % (path))
|
||||||
|
base_dir = tempfile.mkdtemp(dir=path)
|
||||||
|
result = True
|
||||||
|
for char in ['*', '?']:
|
||||||
|
part = "TES" + char + "T"
|
||||||
|
test_dir = os.path.join(base_dir, part)
|
||||||
|
try:
|
||||||
|
os.mkdir(test_dir)
|
||||||
|
except OSError:
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
with os.scandir(base_dir) as entries:
|
||||||
|
if part not in (e.name for e in entries):
|
||||||
|
result = False
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(test_dir)
|
||||||
|
# cleanup
|
||||||
|
os.rmdir(base_dir)
|
||||||
|
logger.debug("path_supports_problematic chars: path=%r result=%s", path, result)
|
||||||
|
return result
|
||||||
|
|||||||
@@ -180,6 +180,9 @@ class Storage(
|
|||||||
self._filesystem_root_folder_is_collision_free,
|
self._filesystem_root_folder_is_collision_free,
|
||||||
filesystem_root_folder_is_collision_free_case_sensitive,
|
filesystem_root_folder_is_collision_free_case_sensitive,
|
||||||
filesystem_root_folder_is_collision_free_no_short_filename)
|
filesystem_root_folder_is_collision_free_no_short_filename)
|
||||||
|
logger.info("Storage location subfolder suppports unicode: %s", pathutils.path_supports_unicode(self._get_collection_root_folder()))
|
||||||
|
logger.info("Storage location subfolder suppports trailing whitespace: %s", pathutils.path_supports_trailing_whitespace(self._get_collection_root_folder()))
|
||||||
|
logger.info("Storage location subfolder suppports problematic chars: %s", pathutils.path_supports_problematic_chars(self._get_collection_root_folder()))
|
||||||
logger.info("Storage cache subfolder usage for 'item': %s", self._use_cache_subfolder_for_item)
|
logger.info("Storage cache subfolder usage for 'item': %s", self._use_cache_subfolder_for_item)
|
||||||
logger.info("Storage cache subfolder usage for 'history': %s", self._use_cache_subfolder_for_history)
|
logger.info("Storage cache subfolder usage for 'history': %s", self._use_cache_subfolder_for_history)
|
||||||
logger.info("Storage cache subfolder usage for 'sync-token': %s", self._use_cache_subfolder_for_synctoken)
|
logger.info("Storage cache subfolder usage for 'sync-token': %s", self._use_cache_subfolder_for_synctoken)
|
||||||
|
|||||||
Reference in New Issue
Block a user