Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/streamclone.py @ 52976:c636f2835c95
stream-bundle: make sure to open the file in binary mode
Windows need an additional flag to open the file properly.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 19 Feb 2025 01:13:00 +0100 |
parents | e4ff37b5317c |
children | 5480647c2964 |
comparison
equal
deleted
inserted
replaced
52975:e4ff37b5317c | 52976:c636f2835c95 |
---|---|
1542 chunks.fill() | 1542 chunks.fill() |
1543 | 1543 |
1544 | 1544 |
1545 def _write_files(info: Iterable[FileInfoT]): | 1545 def _write_files(info: Iterable[FileInfoT]): |
1546 """write files from parsed data""" | 1546 """write files from parsed data""" |
1547 io_flags = os.O_WRONLY | os.O_CREAT | |
1548 if pycompat.iswindows: | |
1549 io_flags |= os.O_BINARY | |
1547 for path, mode, data in info: | 1550 for path, mode, data in info: |
1548 if mode is None: | 1551 if mode is None: |
1549 fd = os.open(path, os.O_WRONLY | os.O_CREAT) | 1552 fd = os.open(path, io_flags) |
1550 else: | 1553 else: |
1551 fd = os.open(path, os.O_WRONLY | os.O_CREAT, mode=mode) | 1554 fd = os.open(path, io_flags, mode=mode) |
1552 try: | 1555 try: |
1553 for chunk in data: | 1556 for chunk in data: |
1554 written = os.write(fd, chunk) | 1557 written = os.write(fd, chunk) |
1555 # write missing pieces if the write was interrupted | 1558 # write missing pieces if the write was interrupted |
1556 while written < len(chunk): | 1559 while written < len(chunk): |