Skip to content

Commit b9b8444

Browse files
author
Diego Argueta
committed
Merge branch 'master' into fix-484
2 parents 6f453cb + a6ea045 commit b9b8444

File tree

9 files changed

+76
-23
lines changed

9 files changed

+76
-23
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- 3.7
1717
- 3.8
1818
- 3.9
19+
- '3.10'
1920
- pypy-2.7
2021
- pypy-3.6
2122
- pypy-3.7
@@ -44,10 +45,10 @@ jobs:
4445
steps:
4546
- name: Checkout code
4647
uses: actions/checkout@v1
47-
- name: Setup Python 3.9
48+
- name: Setup Python 3.10
4849
uses: actions/setup-python@v2
4950
with:
50-
python-version: 3.9
51+
python-version: '3.10'
5152
- name: Install coverage package
5253
run: python -m pip install -U coverage
5354
- name: Download partial coverage reports
@@ -76,10 +77,10 @@ jobs:
7677
steps:
7778
- name: Checkout code
7879
uses: actions/checkout@v1
79-
- name: Setup Python 3.9
80+
- name: Setup Python '3.10'
8081
uses: actions/setup-python@v2
8182
with:
82-
python-version: 3.9
83+
python-version: '3.10'
8384
- name: Update pip
8485
run: python -m pip install -U pip wheel setuptools
8586
- name: Install tox

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212

1313
### Changed
1414

15+
- Support more lenient usernames and group names in FTP servers
16+
([#507](https://github.com/PyFilesystem/pyfilesystem2/pull/507)).
17+
Closes [#506](https://github.com/PyFilesystem/pyfilesystem2/issues/506).
18+
1519
### Fixed
1620

1721
- Fixed `ResourceLocked` error translation on Windows [#484](https://github.com/PyFilesystem/pyfilesystem2/issues/484).
22+
- Fixed `MemoryFS.move` and `MemoryFS.movedir` not updating the name of moved
23+
resources, causing `MemoryFS.scandir` to use the old name.
24+
([#510](https://github.com/PyFilesystem/pyfilesystem2/pull/510)).
25+
Closes [#509](https://github.com/PyFilesystem/pyfilesystem2/issues/509).
1826

1927

2028
## [2.4.14] - 2021-11-16

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Many thanks to the following developers for contributing to this project:
44

5+
- [Adrian Garcia Badaracco](https://github.com/adriangb)
56
- [Alex Povel](https://github.com/alexpovel)
67
- [Andreas Tollkötter](https://github.com/atollk)
78
- [Andrew Scheller](https://github.com/lurch)

fs/_ftp_parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
\s+?
2525
(\d+)
2626
\s+?
27-
([\w\-]+)
27+
([A-Za-z0-9][A-Za-z0-9\-\.\_\@]*\$?)
2828
\s+?
29-
([\w\-]+)
29+
([A-Za-z0-9][A-Za-z0-9\-\.\_\@]*\$?)
3030
\s+?
3131
(\d+)
3232
\s+?

fs/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"ResourceNotFound",
5252
"ResourceReadOnly",
5353
"Unsupported",
54+
"UnsupportedHash",
5455
]
5556

5657

fs/memoryfs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,11 @@ def move(self, src_path, dst_path, overwrite=False, preserve_time=False):
463463
elif not overwrite and dst_name in dst_dir_entry:
464464
raise errors.DestinationExists(dst_path)
465465

466+
# move the entry from the src folder to the dst folder
466467
dst_dir_entry.set_entry(dst_name, src_entry)
467468
src_dir_entry.remove_entry(src_name)
469+
# make sure to update the entry name itself (see #509)
470+
src_entry.name = dst_name
468471

469472
if preserve_time:
470473
copy_modified_time(self, src_path, self, dst_path)
@@ -481,12 +484,16 @@ def movedir(self, src_path, dst_path, create=False, preserve_time=False):
481484
if not src_entry.is_dir:
482485
raise errors.DirectoryExpected(src_path)
483486

487+
# move the entry from the src folder to the dst folder
484488
dst_dir_entry = self._get_dir_entry(dst_dir)
485489
if dst_dir_entry is None or (not create and dst_name not in dst_dir_entry):
486490
raise errors.ResourceNotFound(dst_path)
487491

492+
# move the entry from the src folder to the dst folder
488493
dst_dir_entry.set_entry(dst_name, src_entry)
489494
src_dir_entry.remove_entry(src_name)
495+
# make sure to update the entry name itself (see #509)
496+
src_entry.name = dst_name
490497

491498
if preserve_time:
492499
copy_modified_time(self, src_path, self, dst_path)

fs/test.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,24 @@ def test_copy_dir_temp(self):
17381738
self._test_copy_dir("temp://")
17391739
self._test_copy_dir_write("temp://")
17401740

1741+
def test_move_dir_same_fs(self):
1742+
self.fs.makedirs("foo/bar/baz")
1743+
self.fs.makedir("egg")
1744+
self.fs.writetext("top.txt", "Hello, World")
1745+
self.fs.writetext("/foo/bar/baz/test.txt", "Goodbye, World")
1746+
1747+
fs.move.move_dir(self.fs, "foo", self.fs, "foo2")
1748+
1749+
expected = {"/egg", "/foo2", "/foo2/bar", "/foo2/bar/baz"}
1750+
self.assertEqual(set(walk.walk_dirs(self.fs)), expected)
1751+
self.assert_text("top.txt", "Hello, World")
1752+
self.assert_text("/foo2/bar/baz/test.txt", "Goodbye, World")
1753+
1754+
self.assertEqual(sorted(self.fs.listdir("/")), ["egg", "foo2", "top.txt"])
1755+
self.assertEqual(
1756+
sorted(x.name for x in self.fs.scandir("/")), ["egg", "foo2", "top.txt"]
1757+
)
1758+
17411759
def _test_move_dir_write(self, protocol):
17421760
# Test moving to this filesystem from another.
17431761
other_fs = open_fs(protocol)
@@ -1760,19 +1778,6 @@ def test_move_dir_mem(self):
17601778
def test_move_dir_temp(self):
17611779
self._test_move_dir_write("temp://")
17621780

1763-
def test_move_same_fs(self):
1764-
self.fs.makedirs("foo/bar/baz")
1765-
self.fs.makedir("egg")
1766-
self.fs.writetext("top.txt", "Hello, World")
1767-
self.fs.writetext("/foo/bar/baz/test.txt", "Goodbye, World")
1768-
1769-
fs.move.move_dir(self.fs, "foo", self.fs, "foo2")
1770-
1771-
expected = {"/egg", "/foo2", "/foo2/bar", "/foo2/bar/baz"}
1772-
self.assertEqual(set(walk.walk_dirs(self.fs)), expected)
1773-
self.assert_text("top.txt", "Hello, World")
1774-
self.assert_text("/foo2/bar/baz/test.txt", "Goodbye, World")
1775-
17761781
def test_move_file_same_fs(self):
17771782
text = "Hello, World"
17781783
self.fs.makedir("foo").writetext("test.txt", text)
@@ -1782,6 +1787,9 @@ def test_move_file_same_fs(self):
17821787
self.assert_not_exists("foo/test.txt")
17831788
self.assert_text("foo/test2.txt", text)
17841789

1790+
self.assertEqual(self.fs.listdir("foo"), ["test2.txt"])
1791+
self.assertEqual(next(self.fs.scandir("foo")).name, "test2.txt")
1792+
17851793
def _test_move_file(self, protocol):
17861794
other_fs = open_fs(protocol)
17871795

setup.cfg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ classifiers =
2121
Operating System :: OS Independent
2222
Programming Language :: Python
2323
Programming Language :: Python :: 2.7
24-
Programming Language :: Python :: 3.4
2524
Programming Language :: Python :: 3.5
2625
Programming Language :: Python :: 3.6
2726
Programming Language :: Python :: 3.7
2827
Programming Language :: Python :: 3.8
2928
Programming Language :: Python :: 3.9
29+
Programming Language :: Python :: 3.10
3030
Programming Language :: Python :: Implementation :: CPython
3131
Programming Language :: Python :: Implementation :: PyPy
3232
Topic :: System :: Filesystems
@@ -130,7 +130,7 @@ markers =
130130
# --- Tox automation configuration ---------------------------------------------
131131
132132
[tox:tox]
133-
envlist = py{27,34}{,-scandir}, py{35,36,37,38,39}, pypy{27,36,37}, typecheck, codestyle, docstyle, codeformat
133+
envlist = py{27,34}{,-scandir}, py{35,36,37,38,39,310}, pypy{27,36,37}, typecheck, codestyle, docstyle, codeformat
134134
sitepackages = false
135135
skip_missing_interpreters = true
136136
requires =
@@ -141,9 +141,9 @@ commands = python -m coverage run --rcfile {toxinidir}/setup.cfg -m pytest {posa
141141
deps =
142142
-rtests/requirements.txt
143143
coverage~=5.0
144-
py{35,36,37,38,39,py36,py37}: pytest~=6.0
144+
py{35,36,37,38,39,310,py36,py37}: pytest~=6.0
145145
py{27,34,py27}: pytest~=4.6
146-
py{35,36,37,38,39,py36,py37}: pytest-randomly~=3.5
146+
py{35,36,37,38,39,310,py36,py37}: pytest-randomly~=3.5
147147
py{27,34,py27}: pytest-randomly~=1.2
148148
scandir: .[scandir]
149149
!scandir: .
@@ -183,6 +183,7 @@ python =
183183
3.7: py37
184184
3.8: py38
185185
3.9: py39
186+
3.10: py310
186187
pypy-2.7: pypy27
187188
pypy-3.6: pypy36
188189
pypy-3.7: pypy37

tests/test_ftp_parse.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def test_decode_linux(self, mock_localtime):
5050
drwxr-xr-x 12 0 0 4096 Sep 29 13:13 pub
5151
-rw-r--r-- 1 0 0 26 Mar 04 2010 robots.txt
5252
drwxr-xr-x 8 foo bar 4096 Oct 4 09:05 test
53+
drwxr-xr-x 8 f b 4096 Oct 4 09:05 test
5354
drwxr-xr-x 2 foo-user foo-group 0 Jan 5 11:59 240485
55+
drwxr-xr-x 2 foo.user$ foo@group_ 0 Jan 5 11:59 240485
5456
"""
5557
)
5658

@@ -147,6 +149,18 @@ def test_decode_linux(self, mock_localtime):
147149
"ls": "drwxr-xr-x 8 foo bar 4096 Oct 4 09:05 test"
148150
},
149151
},
152+
{
153+
"access": {
154+
"group": "b",
155+
"permissions": ["g_r", "g_x", "o_r", "o_x", "u_r", "u_w", "u_x"],
156+
"user": "f",
157+
},
158+
"basic": {"is_dir": True, "name": "test"},
159+
"details": {"modified": 1507107900.0, "size": 4096, "type": 1},
160+
"ftp": {
161+
"ls": "drwxr-xr-x 8 f b 4096 Oct 4 09:05 test"
162+
},
163+
},
150164
{
151165
"access": {
152166
"group": "foo-group",
@@ -159,6 +173,18 @@ def test_decode_linux(self, mock_localtime):
159173
"ls": "drwxr-xr-x 2 foo-user foo-group 0 Jan 5 11:59 240485"
160174
},
161175
},
176+
{
177+
"access": {
178+
"group": "foo@group_",
179+
"permissions": ["g_r", "g_x", "o_r", "o_x", "u_r", "u_w", "u_x"],
180+
"user": "foo.user$",
181+
},
182+
"basic": {"is_dir": True, "name": "240485"},
183+
"details": {"modified": 1483617540.0, "size": 0, "type": 1},
184+
"ftp": {
185+
"ls": "drwxr-xr-x 2 foo.user$ foo@group_ 0 Jan 5 11:59 240485"
186+
},
187+
},
162188
]
163189

164190
parsed = ftp_parse.parse(directory.strip().splitlines())

0 commit comments

Comments
 (0)