|
2 | 2 |
|
3 | 3 | import asyncio |
4 | 4 | import os |
| 5 | +import sys |
5 | 6 | import time |
6 | 7 | from collections import OrderedDict |
7 | 8 | from dataclasses import dataclass, field |
@@ -1027,12 +1028,22 @@ async def _quick_count_files(self, directory: Path) -> int: |
1027 | 1028 | Uses subprocess to leverage OS-level file counting which is much faster |
1028 | 1029 | than Python iteration, especially on network filesystems like TigrisFS. |
1029 | 1030 |
|
| 1031 | + On Windows, subprocess is not supported with SelectorEventLoop (which we use |
| 1032 | + to avoid aiosqlite cleanup issues), so we fall back to Python-based counting. |
| 1033 | +
|
1030 | 1034 | Args: |
1031 | 1035 | directory: Directory to count files in |
1032 | 1036 |
|
1033 | 1037 | Returns: |
1034 | 1038 | Number of files in directory (recursive) |
1035 | 1039 | """ |
| 1040 | + # Windows with SelectorEventLoop doesn't support subprocess |
| 1041 | + if sys.platform == "win32": |
| 1042 | + count = 0 |
| 1043 | + async for _ in self.scan_directory(directory): |
| 1044 | + count += 1 |
| 1045 | + return count |
| 1046 | + |
1036 | 1047 | process = await asyncio.create_subprocess_shell( |
1037 | 1048 | f'find "{directory}" -type f | wc -l', |
1038 | 1049 | stdout=asyncio.subprocess.PIPE, |
@@ -1063,13 +1074,20 @@ async def _scan_directory_modified_since( |
1063 | 1074 | This is dramatically faster than scanning all files and comparing mtimes, |
1064 | 1075 | especially on network filesystems like TigrisFS where stat operations are expensive. |
1065 | 1076 |
|
| 1077 | + On Windows, subprocess is not supported with SelectorEventLoop (which we use |
| 1078 | + to avoid aiosqlite cleanup issues), so we fall back to a full directory scan. |
| 1079 | +
|
1066 | 1080 | Args: |
1067 | 1081 | directory: Directory to scan |
1068 | 1082 | since_timestamp: Unix timestamp to find files newer than |
1069 | 1083 |
|
1070 | 1084 | Returns: |
1071 | 1085 | List of relative file paths modified since the timestamp (respects .bmignore) |
1072 | 1086 | """ |
| 1087 | + # Windows with SelectorEventLoop doesn't support subprocess |
| 1088 | + if sys.platform == "win32": |
| 1089 | + return await self._scan_directory_full(directory) |
| 1090 | + |
1073 | 1091 | # Convert timestamp to find-compatible format |
1074 | 1092 | since_date = datetime.fromtimestamp(since_timestamp).strftime("%Y-%m-%d %H:%M:%S") |
1075 | 1093 |
|
|
0 commit comments