diff --git a/src/ert/storage/local_storage.py b/src/ert/storage/local_storage.py index c8f9de3001b..484c2d1ef2b 100644 --- a/src/ert/storage/local_storage.py +++ b/src/ert/storage/local_storage.py @@ -556,6 +556,7 @@ def _write_transaction(self, filename: str | os.PathLike[str], data: bytes) -> N self._swap_path.mkdir(parents=True, exist_ok=True) with NamedTemporaryFile(dir=self._swap_path, delete=False) as f: f.write(data) + os.chmod(f.name, 0o666) os.rename(f.name, filename) def _to_netcdf_transaction( @@ -570,6 +571,7 @@ def _to_netcdf_transaction( self._swap_path.mkdir(parents=True, exist_ok=True) with NamedTemporaryFile(dir=self._swap_path, delete=False) as f: dataset.to_netcdf(f, engine="scipy") + os.chmod(f.name, 0o666) os.rename(f.name, filename) def _to_parquet_transaction( @@ -584,6 +586,7 @@ def _to_parquet_transaction( self._swap_path.mkdir(parents=True, exist_ok=True) with NamedTemporaryFile(dir=self._swap_path, delete=False) as f: dataframe.write_parquet(f.name) + os.chmod(f.name, 0o666) os.rename(f.name, filename) diff --git a/src/ert/storage/migration/to9.py b/src/ert/storage/migration/to9.py index 5d8e07c2399..01febf99488 100644 --- a/src/ert/storage/migration/to9.py +++ b/src/ert/storage/migration/to9.py @@ -19,6 +19,7 @@ def _write_transaction(filename: str | os.PathLike[str], data: bytes) -> None: Path("./swp").mkdir(parents=True, exist_ok=True) with NamedTemporaryFile(dir="./swp", delete=False) as f: f.write(data) + os.chmod(f.name, 0o666) os.rename(f.name, filename) diff --git a/tests/ert/unit_tests/storage/test_local_storage.py b/tests/ert/unit_tests/storage/test_local_storage.py index 2edf11cce8b..814103dac87 100644 --- a/tests/ert/unit_tests/storage/test_local_storage.py +++ b/tests/ert/unit_tests/storage/test_local_storage.py @@ -1,6 +1,7 @@ import json import os import shutil +import stat import tempfile from dataclasses import dataclass, field from datetime import datetime, timedelta @@ -585,6 +586,7 @@ def test_write_transaction(data): filepath = Path("./file.txt") storage._write_transaction(filepath, data) + assert stat.S_IMODE(filepath.stat().st_mode) == 0o666 assert filepath.read_bytes() == data