fix: handle chmod failure on Windows gracefully
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import contextlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -77,11 +78,11 @@ class Config:
|
|||||||
config_path = cls.config_file()
|
config_path = cls.config_file()
|
||||||
with config_path.open("w", encoding="utf-8") as f:
|
with config_path.open("w", encoding="utf-8") as f:
|
||||||
json.dump(config, f, indent=2)
|
json.dump(config, f, indent=2)
|
||||||
config_path.chmod(0o600)
|
|
||||||
except OSError:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
else:
|
with contextlib.suppress(OSError):
|
||||||
return True
|
config_path.chmod(0o600) # may fail on Windows
|
||||||
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_saved(cls) -> dict[str, str]:
|
def apply_saved(cls) -> dict[str, str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user