Skip to content

Commit b115dc3

Browse files
authored
change case insensitivity test (#282)
* change case insensitivity test * changelog
1 parent 2735215 commit b115dc3

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [Unreleased]
8+
## [2.4.5] - 2019-05-05
99

1010
### Fixed
1111

@@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515

1616
### Changed
1717

18-
- Removed case_insensitive meta value from OSFS meta on OSX. normcase check doesn't work on OSX (https://stackoverflow.com/questions/7870041/check-if-file-system-is-case-insensitive-in-python)
18+
- Detect case insensitivity using by writing temp file
1919

2020
## [2.4.4] - 2019-02-23
2121

fs/osfs.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import shutil
1818
import stat
1919
import sys
20+
import tempfile
2021
import typing
2122

2223
import six
@@ -134,7 +135,6 @@ def __init__(
134135
raise errors.CreateFailed("root path does not exist")
135136

136137
_meta = self._meta = {
137-
"case_insensitive": os.path.normcase("Aa") == "aa",
138138
"network": False,
139139
"read_only": False,
140140
"supports_rename": True,
@@ -143,10 +143,14 @@ def __init__(
143143
"virtual": False,
144144
}
145145

146-
if platform.system() == "Darwin":
147-
# Standard test doesn't work on OSX.
148-
# Best we can say is we don't know.
149-
del _meta["case_insensitive"]
146+
try:
147+
# https://stackoverflow.com/questions/7870041/check-if-file-system-is-case-insensitive-in-python
148+
# I don't know of a better way of detecting case insensitivity of a filesystem
149+
with tempfile.NamedTemporaryFile(prefix="TmP") as _tmp_file:
150+
_meta["case_insensitive"] = os.path.exists(_tmp_file.name.lower())
151+
except Exception:
152+
if platform.system() != "Darwin":
153+
_meta["case_insensitive"] = os.path.normcase("Aa") == "aa"
150154

151155
if _WINDOWS_PLATFORM: # pragma: no cover
152156
_meta["invalid_path_chars"] = (

0 commit comments

Comments
 (0)