-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application support path fix #60
Conversation
I discovered that post Path.swift fix the location of the default models folder was inconsistent. This PR creates a new internal API to access the user domain applicationSupportDirectory to improve consistency. If there is an issue with the user domain then this code will fall back to URL.applicationSupportDirectory but under normal operating conditions it should use the app bundle. In the previous code I was using URL.applicationSupportDirectory directly which results in /Users/<uname>/Library/Application Support/hs-diffusion-models Whereas the previous and correct usage is /Users/<uname>/Library/Application Support/<bundle identifier>hf-diffusion-models I've put the new applicationSupportURL function inside Settings. To access it use Settings.shared.applicationSupportURL() Is Settings.shared a reasonable location for such an API? It's not quite a Util function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this issue manifest in practice? Was it using different locations at different times?
It's fine to add this as long as we make sure that:
- It works on iOS and macOS
- It works with/without code signing. The default locations change with code-signing, so maybe that was the reason you were seeing inconsistent paths?
I usually do development on Mac without code signing, but then to distribute the app we need to enable it of course. I think it doesn't matter that the locations don't match, as long as we don't break distribution builds :)
Also, it'd be nice to keep the same download location for distribution builds so people that installed the app from the Mac Store don't need to download the model again.
It was all in macOS Xcode testing, no signing issues. I noticed I didn't properly describe the two locations... I'll make a test project and compare mac vs iOS FileManager vs. URL vs. Path.swift. |
Sample code: Output: FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first FileManager.default.temporaryDirectory Path.applicationSupport / "hf-diffusion-models" URL.applicationSupportDirectory.appendingPathComponent("hf-diffusion-models") macOS test: URL.applicationSupportDirectory FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first FileManager.default.temporaryDirectory Path.applicationSupport / "hf-diffusion-models" URL.applicationSupportDirectory.appendingPathComponent("hf-diffusion-models") Result: these are pretty consistent actually. Therefore, to avoid accidental misshapen code I thought it would make sense to have our own internal API to call on the correct folder rather than reconstructing it each time we want to interact. Do you think that this submission, given the comparable results above, is overkill? |
Oh, I see. Do you know when was this happening? |
@@ -14,7 +14,7 @@ import ZIPFoundation | |||
import StableDiffusion | |||
|
|||
class PipelineLoader { | |||
static let models = URL.applicationSupportDirectory.appendingPathComponent("hf-diffusion-models") | |||
static let models = Settings.shared.applicationSupportURL().appendingPathComponent("hf-diffusion-models") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing app bundle folder container.
remove bundle identifier in path to ensure backward compatibility with current live release version.
I discovered that post Path.swift fix the location of the default models folder was inconsistent. This PR creates a new internal API to access the user domain applicationSupportDirectory to improve consistency. If there is an issue with the user domain then this code will fall back to URL.applicationSupportDirectory but under normal operating conditions it should use the app bundle.
In the previous code I was using URL.applicationSupportDirectory directly which results in /Users//Library/Application Support/hs-diffusion-models
Whereas the previous and correct usage is
/Users//Library/Application Support/hf-diffusion-models
I've put the new applicationSupportURL function inside Settings. To access it use Settings.shared.applicationSupportURL()
Is Settings.shared a reasonable location for such an API? It's not quite a Util function.
(Note: this is extracted from the last commit to #59 and should commit before and then merge back into 59 before it's reviewed.)