diff --git a/lib/model/store.dart b/lib/model/store.dart index 3a3b59bea08..6800fc6af10 100644 --- a/lib/model/store.dart +++ b/lib/model/store.dart @@ -778,19 +778,22 @@ class LiveGlobalStore extends GlobalStore { /// The file path to use for the app database. static Future _dbFile() async { - // What directory should we use? - // path_provider's getApplicationSupportDirectory: - // on Android, -> Flutter's PathUtils.getFilesDir -> https://developer.android.com/reference/android/content/Context#getFilesDir() - // -> empirically /data/data/com.zulip.flutter/files/ - // on iOS, -> "Library/Application Support" via https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsapplicationsupportdirectory - // on Linux, -> "${XDG_DATA_HOME:-~/.local/share}/com.zulip.flutter/" - // All seem reasonable. - // path_provider's getApplicationDocumentsDirectory: - // on Android, -> Flutter's PathUtils.getDataDirectory -> https://developer.android.com/reference/android/content/Context#getDir(java.lang.String,%20int) - // with https://developer.android.com/reference/android/content/Context#MODE_PRIVATE - // on iOS, "Document directory" via https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsdocumentdirectory - // on Linux, -> `xdg-user-dir DOCUMENTS` -> e.g. ~/Documents - // That Linux answer is definitely not a fit. Harder to tell about the rest. + // path_provider's getApplicationSupportDirectory: + // on Android, -> Flutter's PathUtils.getFilesDir -> https://developer.android.com/reference/android/content/Context#getFilesDir() + // -> empirically /data/data/com.zulip.flutter/files/ + // on iOS, -> "Library/Application Support" via https://developer.apple.com/documentation/foundation/nssearchpathdirectory/nsapplicationsupportdirectory + // on Linux, -> "${XDG_DATA_HOME:-~/.local/share}/com.zulip.flutter/" + // + // This is reasonable for iOS per Apple's recommendation: + // > Use ["Library/Application Support"] to store all app data files except + // > those associated with the user’s documents. For example, you might use + // > this directory to store app-created data files, configuration files, + // > templates, or other fixed or modifiable resources that are managed by + // > the app. + // See: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW2 + // + // The paths are reasonable for both Android and Linux, compared to the + // ones from using path_provider's getApplicationDocumentsDirectory. final dir = await getApplicationSupportDirectory(); return File(p.join(dir.path, 'zulip.db')); }