Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

Exception when `configs/settings.yml` is read-only

Open nicomem opened this issue 1 year ago • 1 comments

Describe the bug

I have the configs/settings.yml file with read-only permissions, but when running Stirling-PDF I get the following error:

18:25:47.534 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.RuntimeException: Failed to initialize application configuration
        at stirling.software.SPDF.config.ConfigInitializer.initialize(ConfigInitializer.java:30)
        at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:627)
        at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:400)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
        at stirling.software.SPDF.SPdfApplication.main(SPdfApplication.java:75)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:10>
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:91)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)
Caused by: java.nio.file.FileSystemException: configs/settings.yml: Read-only file system
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:261)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:482)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:227)
        at java.base/java.nio.file.Files.write(Files.java:3561)
        at stirling.software.SPDF.config.ConfigInitializer.mergeYamlFiles(ConfigInitializer.java:162)
        at stirling.software.SPDF.config.ConfigInitializer.ensureConfigExists(ConfigInitializer.java:64)
        at stirling.software.SPDF.config.ConfigInitializer.initialize(ConfigInitializer.java:28)
        ... 9 common frames omitted

Expected behavior

Stirling-PDF should open the configs/settings.yml file as read-only, and only try to write the file if it does not already exist.

nicomem avatar Apr 21 '24 16:04 nicomem

Currently Stirling pdf does rewrite the config file on startup as it checks for new configs to add and remove. Effectively recreating the file every startup but carrying over settings between versions

Frooodle avatar Apr 21 '24 16:04 Frooodle