fix: publish new Windows outputs without requiring hard links
This commit is contained in:
@@ -14,7 +14,9 @@ _UNCHECKED = object()
|
||||
def fingerprint(path: Path):
|
||||
try:
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
digest = hashlib.sha256()
|
||||
for block in iter(lambda: stream.read(1024 * 1024), b''): digest.update(block)
|
||||
return digest.hexdigest()
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
@@ -42,7 +44,9 @@ def _checked_replace(temporary: Path, path: Path, expected: str | None) -> None:
|
||||
raise OSError(f'文件发生变化,已停止替换:{path}')
|
||||
if expected is None:
|
||||
# Creating the directory entry must fail if another process got there first.
|
||||
os.link(temporary, path)
|
||||
# Windows rename is exclusive and also works on volumes without hardlinks.
|
||||
if os.name == 'nt': os.rename(temporary, path)
|
||||
else: os.link(temporary, path)
|
||||
return
|
||||
backup = _recovery_path(path)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user