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

ios: fix exporting files (CSV exports, log export, notes export) #2939

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benma
Copy link
Contributor

@benma benma commented Sep 27, 2024

Similar to Android, we set ExportsDir() to "" and let the backend environment getSaveFilename() construct the full path.

Mobile handling of the dirs/files is a big hack and works on implicit assumptions, e.g. that getSaveFilename() is always called with filepath.Join(exportsDir, filename), which is only the filename on mobile as ExportsDir() returns "". This should be cleaned up, but for now iOS is made to behave like Android in this regard.

@benma benma marked this pull request as draft September 27, 2024 21:05
@benma benma marked this pull request as ready for review September 30, 2024 12:26
Similar to Android, we set `ExportsDir()` to `""` and let
the backend environment `getSaveFilename()` construct the full path.

Mobile handling of the dirs/files is a big hack and works on implicit
assumptions, e.g. that `getSaveFilename()` is always called with
`filepath.Join(exportsDir, filename)`, which is only the filename on
mobile as `ExportsDir()` returns `""`. This should be cleaned up, but
for now iOS is made to behave like Android in this regard.

We use a temp directory for these files, so the files will be cleaned
up automatically after a while.
@benma
Copy link
Contributor Author

benma commented Oct 10, 2024

Ping @Beerosagos in case you missed it

class GoEnvironment: NSObject, MobileserverGoEnvironmentInterfaceProtocol, UIDocumentInteractionControllerDelegate {
func getSaveFilename(_ fileName: String?) -> String {
let tempDirectory = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
let fileURL = tempDirectory.appendingPathComponent(fileName!)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a guard for fileName, like the one used in systemOpen for the urlString

return scene.windows.first(where: { $0.isKeyWindow })?.rootViewController
}

func systemOpen(_ urlString: String?) throws {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function doesn't throw any exception, I think you can remove the throws keyword

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.

2 participants