Fix FileFeedStorage handling of Windows paths without file:// scheme (#6897)

This commit is contained in:
Thalison Fernandes 2025-06-23 13:56:29 -03:00 committed by Andrey Rakhmatullin
parent 843ad1afb1
commit 5e20b46e35
2 changed files with 6 additions and 1 deletions

View File

@ -185,7 +185,7 @@ class StdoutFeedStorage:
@implementer(IFeedStorage)
class FileFeedStorage:
def __init__(self, uri: str, *, feed_options: dict[str, Any] | None = None):
self.path: str = file_uri_to_path(uri)
self.path: str = file_uri_to_path(uri) if uri.startswith("file://") else uri
feed_options = feed_options or {}
self.write_mode: OpenBinaryMode = (
"wb" if feed_options.get("overwrite", False) else "ab"

View File

@ -143,6 +143,11 @@ class TestFileFeedStorage(unittest.TestCase):
finally:
path.unlink()
def test_preserves_windows_path_without_file_scheme(self):
path = r"C:\Users\user\Desktop\test.txt"
storage = FileFeedStorage(path)
assert storage.path == path
class TestFTPFeedStorage(unittest.TestCase):
def get_test_spider(self, settings=None):