summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-07 20:57:52 -0400
committerMason Reed <mason@vector35.com>2025-04-07 21:11:17 -0400
commitf3f43af65e86b6b9b8a40b33a694efa1779616fe (patch)
tree6268549b8503f923b6340e8b81d767c1611b9de1 /view/sharedcache/core/SharedCache.cpp
parenta976ebde53b234a1f6caf95c3258d2477fda17e2 (diff)
[SharedCache] Allow the user to select the original shared cache file on disk
This gives the user the ability to take a database with no original file path continue processing entries with the user supplied base file. This also will set the original file path for future loads, we might want to make that optional. And the behavior with remote projects for that might be undesired.
Diffstat (limited to 'view/sharedcache/core/SharedCache.cpp')
-rw-r--r--view/sharedcache/core/SharedCache.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp
index bfb10d90..0b8653d7 100644
--- a/view/sharedcache/core/SharedCache.cpp
+++ b/view/sharedcache/core/SharedCache.cpp
@@ -553,6 +553,19 @@ bool CacheProcessor::ProcessFileCache(SharedCache& cache)
std::string baseFilePath = m_view->GetFile()->GetOriginalFilename();
std::string baseFileName = BaseFileName(baseFilePath);
+ // If we don't have an original file path, prompt the user to select one.
+ if (baseFilePath.empty())
+ {
+ if (!GetOpenFileNameInput(baseFilePath, "Please select the base shared cache file"))
+ {
+ // User did not give a file, tell them that we will try and scan the file directory.
+ m_logger->LogWarn("Failed to get original file path, will try and scan the file directory.");
+ }
+ // Update so next load we don't need to prompt the user.
+ // TODO: What happens for a remote project? This will point at what exactly?
+ m_view->GetFile()->SetOriginalFilename(baseFilePath);
+ }
+
// Add this file to the entries
try
{
@@ -614,11 +627,24 @@ bool CacheProcessor::ProcessFileCache(SharedCache& cache)
bool CacheProcessor::ProcessProjectCache(SharedCache& cache)
{
auto baseProjectFile = m_view->GetFile()->GetProjectFile();
+ auto baseProjectFileFolder = baseProjectFile->GetFolder();
std::string baseFilePath = baseProjectFile->GetPathOnDisk();
std::string baseFileName = baseProjectFile->GetName();
// This will point to the path on disk for original non-bndb file.
std::string originalFilePath = m_view->GetFile()->GetOriginalFilename();
+ // If we don't have an original file path, prompt the user to select one.
+ if (originalFilePath.empty())
+ {
+ if (!GetOpenFileNameInput(originalFilePath, "Please select the base shared cache file"))
+ {
+ // User did not give a file, tell them that we will try and scan the project directory.
+ m_logger->LogWarn("Failed to get original file path, will try and scan the project directory.");
+ }
+ // Update so next load we don't need to prompt the user.
+ m_view->GetFile()->SetOriginalFilename(originalFilePath);
+ }
+
// Remove the .bndb extension if present ("dyld_shared_cache_arm64e.bndb" => "dyld_shared_cache_arm64e)
// TODO: This is a little annoying, we need to do this because the file accessor we have is separate
// TODO: from the view file accessor. If we either made it so that we can parse from the BNDB file accessor,
@@ -629,6 +655,12 @@ bool CacheProcessor::ProcessProjectCache(SharedCache& cache)
// Search for the backing file.
for (const auto& projectFile : baseProjectFile->GetProject()->GetFiles())
{
+ // Skip files not in the same folder.
+ auto projectFileFolder = projectFile->GetFolder();
+ if (baseProjectFileFolder && projectFileFolder)
+ if (baseProjectFileFolder->GetId() != projectFileFolder->GetId())
+ continue;
+
auto projectFilePath = projectFile->GetPathOnDisk();
auto projectFileName = projectFile->GetName();
if (projectFileName == baseFileName || projectFilePath == originalFilePath)