diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-17 21:00:44 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-17 21:00:44 -0400 |
| commit | 620c04f75ad0f6025cc26f73dd07c466d6e1c62e (patch) | |
| tree | a96afdb471cd6b475d766463987f03807c6f0a89 | |
| parent | ad0ba0fc61f83e2aaf22192e7d0ad05dde9ffd62 (diff) | |
| download | decky-lsfg-vk-620c04f75ad0f6025cc26f73dd07c466d6e1c62e.tar.gz decky-lsfg-vk-620c04f75ad0f6025cc26f73dd07c466d6e1c62e.zip | |
fix config writes
| -rw-r--r-- | justfile | 2 | ||||
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/base_service.py | 37 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/configuration.py | 10 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/installation.py | 4 |
5 files changed, 20 insertions, 35 deletions
@@ -5,7 +5,7 @@ build: sudo rm -rf node_modules && .vscode/build.sh test: - scp "/Users/kurt/Developer/decky-lossless-scaling-vk/out/Lossless Scaling.zip" deck@192.168.0.6:~/Desktop + scp "/var/home/bazzite/decky-lossless-scaling-vk/out/Lossless Scaling.zip" deck@192.168.0.6:~/Desktop clean: rm -rf node_modules dist
\ No newline at end of file diff --git a/package.json b/package.json index df7ba84..adcbe1c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ { "name": "lsfg-vk_archlinux.zip", "url": "https://github.com/xXJSONDeruloXx/lsfg-vk/releases/download/pre-conf-jul16/lsfg-vk_archlinux.zip", - "sha256hash": "c9eb86e0ef458395fca18161b1620855b21eee54aa1df536a5fbbd2d524b1b88" + "sha256hash": "d44add7cec95a54f36e0b48fd3f509fda6852ff25127d58574a9ee31a9885864" } ], "pnpm": { diff --git a/py_modules/lsfg_vk/base_service.py b/py_modules/lsfg_vk/base_service.py index 92ac152..a796480 100644 --- a/py_modules/lsfg_vk/base_service.py +++ b/py_modules/lsfg_vk/base_service.py @@ -4,7 +4,6 @@ Base service class with common functionality. import os import shutil -import tempfile from pathlib import Path from typing import Any, Optional @@ -65,8 +64,8 @@ class BaseService: self.log.info(f"File not found: {path}") return False - def _atomic_write(self, path: Path, content: str, mode: int = 0o644) -> None: - """Write content to a file atomically + def _write_file(self, path: Path, content: str, mode: int = 0o644) -> None: + """Write content to a file Args: path: Target file path @@ -76,31 +75,17 @@ class BaseService: Raises: OSError: If write fails """ - # Create temporary file in the same directory to ensure atomic move - temp_path = None try: - with tempfile.NamedTemporaryFile( - mode='w', - dir=path.parent, - delete=False, - prefix=f'.{path.name}.', - suffix='.tmp' - ) as temp_file: - temp_file.write(content) - temp_path = Path(temp_file.name) + # Write directly to the file + with open(path, 'w', encoding='utf-8') as f: + f.write(content) + f.flush() # Ensure data is written to disk + os.fsync(f.fileno()) # Force filesystem sync - # Set permissions before moving - temp_path.chmod(mode) - - # Atomic move - temp_path.replace(path) - self.log.info(f"Atomically wrote to {path}") + # Set permissions + path.chmod(mode) + self.log.info(f"Wrote to {path}") except Exception: - # Clean up temp file if something went wrong - if temp_path and temp_path.exists(): - try: - temp_path.unlink() - except OSError: - pass # Best effort cleanup + self.log.error(f"Failed to write to {path}") raise diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index c15fc37..a4fcae5 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -89,11 +89,11 @@ class ConfigurationService(BaseService): # Generate TOML content using centralized manager toml_content = ConfigurationManager.generate_toml_content(config) - # Ensure config directory exists + # Ensure config directory exists self.config_dir.mkdir(parents=True, exist_ok=True) - # Write the updated config atomically - self._atomic_write(self.config_file_path, toml_content, 0o644) + # Write the updated config directly to preserve inode for file watchers + self._write_file(self.config_file_path, toml_content, 0o644) self.log.info(f"Updated lsfg TOML configuration: enable={enable}, " f"dll='{dll}', multiplier={multiplier}, flow_scale={flow_scale}, " @@ -154,8 +154,8 @@ class ConfigurationService(BaseService): # Ensure config directory exists self.config_dir.mkdir(parents=True, exist_ok=True) - # Write the updated config atomically - self._atomic_write(self.config_file_path, toml_content, 0o644) + # Write the updated config directly to preserve inode for file watchers + self._write_file(self.config_file_path, toml_content, 0o644) self.log.info(f"Updated DLL path in lsfg configuration: '{dll_path}'") diff --git a/py_modules/lsfg_vk/installation.py b/py_modules/lsfg_vk/installation.py index 27be850..fc9ac97 100644 --- a/py_modules/lsfg_vk/installation.py +++ b/py_modules/lsfg_vk/installation.py @@ -114,8 +114,8 @@ class InstallationService(BaseService): # Generate TOML content using centralized manager toml_content = ConfigurationManager.generate_toml_content(config) - # Use atomic write to prevent corruption - self._atomic_write(self.config_file_path, toml_content, 0o644) + # Write initial config file + self._write_file(self.config_file_path, toml_content, 0o644) self.log.info(f"Created config file at {self.config_file_path}") # Log detected DLL path if found |
