voicesmith-mcp 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.py +18 -2
- package/package.json +1 -1
package/config.py
CHANGED
|
@@ -7,6 +7,7 @@ Environment variables override individual config values.
|
|
|
7
7
|
|
|
8
8
|
import json
|
|
9
9
|
import os
|
|
10
|
+
import tempfile
|
|
10
11
|
from dataclasses import dataclass, field, asdict
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Optional
|
|
@@ -207,7 +208,22 @@ def save_config(config: AppConfig, config_path: Optional[Path] = None) -> None:
|
|
|
207
208
|
},
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
# Atomic write: write to temp file then rename. This prevents
|
|
212
|
+
# readers (like the installer) from seeing a truncated file if
|
|
213
|
+
# they read during a write.
|
|
214
|
+
try:
|
|
215
|
+
fd, tmp_path = tempfile.mkstemp(
|
|
216
|
+
dir=path.parent, suffix=".tmp", prefix=".config-"
|
|
217
|
+
)
|
|
218
|
+
with os.fdopen(fd, "w") as f:
|
|
219
|
+
json.dump(data, f, indent=2)
|
|
220
|
+
os.replace(tmp_path, path)
|
|
221
|
+
except Exception as e:
|
|
222
|
+
# Clean up temp file if rename failed
|
|
223
|
+
try:
|
|
224
|
+
os.unlink(tmp_path)
|
|
225
|
+
except OSError:
|
|
226
|
+
pass
|
|
227
|
+
raise
|
|
212
228
|
|
|
213
229
|
logger.debug(f"Saved config to {path}")
|
package/package.json
CHANGED