Skip to content

Commit

Permalink
change case insensitivity test (#282)
Browse files Browse the repository at this point in the history
* change case insensitivity test

* changelog
  • Loading branch information
willmcgugan authored May 5, 2019
1 parent 2735215 commit b115dc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [2.4.5] - 2019-05-05

### Fixed

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

### Changed

- 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)
- Detect case insensitivity using by writing temp file

## [2.4.4] - 2019-02-23

Expand Down
14 changes: 9 additions & 5 deletions fs/osfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import shutil
import stat
import sys
import tempfile
import typing

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

_meta = self._meta = {
"case_insensitive": os.path.normcase("Aa") == "aa",
"network": False,
"read_only": False,
"supports_rename": True,
Expand All @@ -143,10 +143,14 @@ def __init__(
"virtual": False,
}

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

if _WINDOWS_PLATFORM: # pragma: no cover
_meta["invalid_path_chars"] = (
Expand Down

0 comments on commit b115dc3

Please sign in to comment.