Skip to content

Commit

Permalink
chore: revert back to previous storage locations until we have a migr…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
justin-fiedler committed Feb 2, 2024
1 parent 1a5771d commit 56ef5b9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Sources/Amplitude/Storages/PersistentStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,16 @@ extension PersistentStorage {
}

internal func getEventsStorageDirectory(createDirectory: Bool = true) -> URL {
let searchPathDirectory = FileManager.SearchPathDirectory.applicationSupportDirectory
// TODO: Update to use applicationSupportDirectory for all platforms (this will require a migration)
// let searchPathDirectory = FileManager.SearchPathDirectory.applicationSupportDirectory
// tvOS doesn't have access to document
// macOS /Documents dir might be synced with iCloud
#if os(tvOS) || os(macOS)
let searchPathDirectory = FileManager.SearchPathDirectory.cachesDirectory
#else
let searchPathDirectory = FileManager.SearchPathDirectory.documentDirectory
#endif

// Make sure Amplitude data is sandboxed per app
let appPath = sandboxHelper.isSandboxEnabled() ? "" : "\(Bundle.main.bundleIdentifier!)/"

Expand All @@ -249,11 +258,7 @@ extension PersistentStorage {
if createDirectory {
// try to create it, will fail if already exists.
// tvOS, watchOS regularly clear out data.
var values = URLResourceValues()
values.isExcludedFromBackup = true
try? FileManager.default.createDirectory(
at: storageUrl, withIntermediateDirectories: true, attributes: nil)
try? storageUrl.setResourceValues(values)
try? FileManager.default.createDirectory(at: storageUrl, withIntermediateDirectories: true, attributes: nil)
}
return storageUrl
}
Expand Down

0 comments on commit 56ef5b9

Please sign in to comment.