From 115d54202d5c35b54b5ec923ec3206fc779a7b38 Mon Sep 17 00:00:00 2001 From: Aiqin Zhang Date: Wed, 24 Apr 2024 16:23:18 +1000 Subject: [PATCH] Fix permission issue for m3db Fix permission issue for m3db --- astacus/node/clear.py | 5 ++++- astacus/node/download.py | 2 +- astacus/node/sqlite_snapshot.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/astacus/node/clear.py b/astacus/node/clear.py index d1c942f6..6252f795 100644 --- a/astacus/node/clear.py +++ b/astacus/node/clear.py @@ -40,6 +40,9 @@ def clear(self) -> None: progress.start(len(self.snapshotter.snapshot)) for relative_path in self.snapshotter.snapshot.get_all_paths(): absolute_path = self.config.root / relative_path - absolute_path.unlink(missing_ok=True) + try: + absolute_path.unlink(missing_ok=True) + except PermissionError as e: + logger.error("Failed to clear: %s", absolute_path) progress.add_success() progress.done() diff --git a/astacus/node/download.py b/astacus/node/download.py index 6bdcbbb2..c03ba394 100644 --- a/astacus/node/download.py +++ b/astacus/node/download.py @@ -52,7 +52,7 @@ def _download_snapshotfile(self, snapshotfile: ipc.SnapshotFile) -> None: relative_path = snapshotfile.relative_path download_path = self.dst / relative_path - download_path.parent.mkdir(parents=True, exist_ok=True) + download_path.parent.mkdir(parents=True, exist_ok=True, mode=0o770) with utils.open_path_with_atomic_rename(download_path) as f: if snapshotfile.hexdigest: self.local_storage.download_hexdigest_to_file(snapshotfile.hexdigest, f) diff --git a/astacus/node/sqlite_snapshot.py b/astacus/node/sqlite_snapshot.py index a9c1235e..13d959c3 100644 --- a/astacus/node/sqlite_snapshot.py +++ b/astacus/node/sqlite_snapshot.py @@ -127,7 +127,7 @@ def _list_files_and_create_directories(self) -> Iterable[str]: if any(parent.name == magic.ASTACUS_TMPDIR for parent in dir_path.parents): continue rel_dir = dir_path.relative_to(self._src) - (self._dst / rel_dir).mkdir(parents=True, exist_ok=True) + (self._dst / rel_dir).mkdir(parents=True, exist_ok=True, mode=0o770) for f in files: rel_path = str(rel_dir / f) if not (dir_path / f).is_symlink() and self._groups.any_match(rel_path):