Skip to content

Commit c970cdc

Browse files
committed
attempt to fix broken file writes on windows
1 parent cc31a10 commit c970cdc

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

file_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ def store_response_files(target_folder, response_files, existing_files):
219219

220220
os.makedirs(os.path.dirname(full_file_name), exist_ok=True)
221221

222+
# On Windows, an existing file may have the read-only attribute set (e.g. files
223+
# restored from zip, copied from network shares, or touched by certain tools),
224+
# which causes open(..., "w") to raise PermissionError. Clear it first, mirroring
225+
# the pattern used for deletion via _make_writable.
226+
if os.path.exists(full_file_name):
227+
_make_writable(full_file_name)
228+
222229
with open(full_file_name, "w") as f:
223230
# console.info(f"OLA writing to file {file_name} content before: {}")
224231
console.info(f"OLA writing to file {file_name} content after: {response_files[file_name]}")

0 commit comments

Comments
 (0)