Skip to content
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

Create fronted cache if not found. #1469

Closed
wants to merge 1 commit into from
Closed

Conversation

jigar-f
Copy link
Contributor

@jigar-f jigar-f commented Dec 13, 2024

This PR fixes the issue where a fronted cache file is not found; if it is not found, then it is created.

@myleshorton
Copy link
Contributor

This is already handled here:

https://github.com/getlantern/fronted/blob/main/cache.go#L88

@jigar-f
Copy link
Contributor Author

jigar-f commented Dec 13, 2024

Then how come every time it throws error with file being not found.

I might be missing something here.

@jigar-f
Copy link
Contributor Author

jigar-f commented Dec 16, 2024

Something like this

Dec 16 07:06:39.628 - 9m48s ERROR fronted: cache.go:90 Unable to save cache to disk: open /private/var/mobile/Containers/Data/Application/9ED85F72-5D40-424F-932E-BD39A3CFB30E/Library/Application Support/Lantern/fronted_cache.json: no such file or directory [error=Unable to save cache to disk: %v error_location=github.com/getlantern/fronted.(*fronted).updateCache (cache.go:90) error_op=open error_text=Unable to save cache to disk: open /private/var/mobile/Containers/Data/Application/9ED85F72-5D40-424F-932E-BD39A3CFB30E/Library/Application Support/Lantern/fronted_cache.json: no such file or directory error_type=errors.Error]
ERROR fronted: cache.go:90   at github.com/getlantern/fronted.(*fronted).updateCache (cache.go:90)
ERROR fronted: cache.go:90   at github.com/getlantern/fronted.(*fronted).maintainCache (cache.go:70)
ERROR fronted: cache.go:90   at runtime.goexit (asm_arm64.s:1222)
ERROR fronted: cache.go:90 Caused by: open /private/var/mobile/Containers/Data/Application/9ED85F72-5D40-424F-932E-BD39A3CFB30E/Library/Application Support/Lantern/fronted_cache.json: no such file or directory
ERROR fronted: cache.go:90 Caused by: no such file or directory

cc @garmr-ulfr

@garmr-ulfr
Copy link
Contributor

Yeah, I'm also getting the same error.

This is already handled here:

https://github.com/getlantern/fronted/blob/main/cache.go#L88

While os.WriteFile does create a file if it doesn't exist, it doesn't create the parent directory, which is what's causing the issue. Instead this PR, we just need to add os.MkdirAll to fronted before trying to write to the file.

@jigar-f
Copy link
Contributor Author

jigar-f commented Dec 18, 2024

Thanks, @garmr-ulfr Let me do some testing.

@garmr-ulfr
Copy link
Contributor

Closing as this change was added to fronted instead.

@garmr-ulfr garmr-ulfr closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants