Repository navigation
Implement hardResetDatabase method #2
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
Open
orca-nazar
wants to merge
9
commits into
main
Choose a base branch
from
provide-offline-manager-reinit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c59df18
Implement hardResetDatabase on iOS
orca-nazar ce219cc
Provide hardResetDatabase on Android
orca-nazar 24765ef
Update bridge
orca-nazar 8004e4b
Fixes after review
orca-nazar 6229bfd
Align Android hardResetDatabase with iOS implementation
orca-nazar ac3189f
Merge branch 'main' into provide-offline-manager-reinit
orca-nazar 2546275
Fixes after review
orca-nazar 49009a6
Extend UUID
orca-nazar 76a5eac
Resolve new map data path in shared util
orca-nazar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
android/src/main/java/com/rnmapbox/rnmbx/utils/MapDataPath.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.rnmapbox.rnmbx.utils | ||
|
|
||
| import java.io.File | ||
| import java.util.UUID | ||
|
|
||
| fun resolveMapDataPath(filesDir: File): File { | ||
| val defaultMapDataDir = File(filesDir, ".mapbox/map_data") | ||
| val customRoot = File(filesDir, ".mapbox_custom") | ||
|
|
||
| if (customRoot.exists()) { | ||
| customRoot.listFiles { entry -> entry.isDirectory }?.forEach { entry -> | ||
| val candidateMapData = File(entry, "map_data") | ||
| val candidateDb = File(candidateMapData, "map_data.db") | ||
|
|
||
| if (candidateDb.exists()) { | ||
| return candidateMapData | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return defaultMapDataDir | ||
| } | ||
|
|
||
| fun newMapDataPath(filesDir: File): File { | ||
| return File(filesDir, ".mapbox_custom/${UUID.randomUUID()}/map_data") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import Foundation | ||
|
|
||
| private let RNMBXMapDataPathErrorDomain = "RNMBXMapDataPath" | ||
|
|
||
| func RNMBXApplicationSupportDirectory() throws -> URL { | ||
| guard let appSupport = FileManager.default.urls( | ||
| for: .applicationSupportDirectory, | ||
| in: .userDomainMask | ||
| ).first else { | ||
| throw NSError( | ||
| domain: RNMBXMapDataPathErrorDomain, | ||
| code: 1, | ||
| userInfo: [NSLocalizedDescriptionKey: "Application Support directory unavailable"] | ||
| ) | ||
| } | ||
|
|
||
| return appSupport | ||
| } | ||
|
|
||
| func RNMBXMapDataPath() throws -> URL { | ||
| let fileManager = FileManager.default | ||
| let appSupport = try RNMBXApplicationSupportDirectory() | ||
| let defaultDataPath = appSupport.appendingPathComponent(".mapbox/map_data", isDirectory: true) | ||
| let customRoot = appSupport.appendingPathComponent(".mapbox_custom", isDirectory: true) | ||
|
|
||
| guard fileManager.fileExists(atPath: customRoot.path), | ||
| let entries = try? fileManager.contentsOfDirectory( | ||
| at: customRoot, | ||
| includingPropertiesForKeys: [.isDirectoryKey], | ||
| options: [] | ||
| ) else { | ||
| return defaultDataPath | ||
| } | ||
|
|
||
| for entry in entries { | ||
| if let isDir = try? entry.resourceValues(forKeys: [.isDirectoryKey]).isDirectory, | ||
| isDir == true { | ||
| let candidateMapData = entry.appendingPathComponent("map_data", isDirectory: true) | ||
| let candidateDb = candidateMapData.appendingPathComponent("map_data.db") | ||
|
|
||
| if fileManager.fileExists(atPath: candidateDb.path) { | ||
| return candidateMapData | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return defaultDataPath | ||
| } | ||
|
|
||
| func RNMBXNewMapDataPath() throws -> URL { | ||
| let appSupport = try RNMBXApplicationSupportDirectory() | ||
| return appSupport.appendingPathComponent( | ||
| ".mapbox_custom/\(UUID().uuidString)/map_data", | ||
| isDirectory: true | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.