FileStorageKey (Default) Creates Empty File Instead of Populating It with Data #167
Replies: 4 comments
-
Hi @zachgibson, this is currently by design. We do not eagerly write the initial value to the external system (in any strategy, including Can you describe what problem this is causing for you so that we can evaluate? But since this isn't an issue with the library I am going to convert it to a discussion. Let's continue the conversation over there! |
Beta Was this translation helpful? Give feedback.
-
I see @mbrandonw, this makes sense. I guess I'm just using it in an unexpected way. My use-case is a Metal shader "REPL-like" app. When saving your shader externally Sharing picks that up and we re-compile/draw the new shader. So, when someone creates a new shader in the app I default the string to a sample shader program that has all the necessary boilerplate. This is where I am needing the file to have the contents initially. |
Beta Was this translation helpful? Give feedback.
-
I'm down to handle this in my own way but I haven't thought of a reliable mechanism to know when to update the state to cause it to be written to the file. |
Beta Was this translation helpful? Give feedback.
-
For now I'm creating the file and seeding the contents myself at creation time. @mbrandonw any considerations here or is this totally fine? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When using
FileStorageKey<String>.Default
, I’m seeing an issue where the file is created on disk with no contents, even though a default value is provided and used in memory. If I update that state the file then gets populated correctly.Checklist
main
branch of this package.Expected behavior
FileStorageKey<T>.Default
with a non-nil default value creates a file on disk with the contents of default value.Actual behavior
FileStorageKey<T>.Default
with a non-nil default value creates an empty file on disk.Reproducing project
FileStorageRepro.zip
Sharing version information
2.5.2
Destination operating system
macOS 15.3.1
Xcode version information
16.2
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions