Skip to content

Exported Files Not Visible in Quest Files App Until Restart #6

@samuelm2

Description

@samuelm2

🐛 Bug Description

When using the "Export Data" feature to export recordings to the Quest Downloads folder, the ZIP file is successfully created but does not appear in the Quest Files app until the headset is restarted.

Current Behavior:

  1. User exports a recording via Y button → Recording Menu → "Export Data"
  2. Export completes successfully (confirmation message appears)
  3. User opens Quest Files app → Downloads folder
  4. ❌ ZIP file is not visible
  5. User restarts headset
  6. ✅ ZIP file now appears in Downloads folder

Expected Behavior:

  • ZIP file should be immediately visible in Quest Files app after export completes

📍 Location

File: Assets/RealityLog/Scripts/Runtime/FileOperations/RecordingOperations.cs

Export Code (lines ~298-301):

// Move zip to downloads
File.Move(zipPath, destZipPath);

Debug.Log($"[{Constants.LOG_TAG}] RecordingOperations: Exported {directoryName} to {destZipPath}");
OnOperationComplete?.Invoke("Export", true, $"Exported to Downloads: {Path.GetFileName(destZipPath)}. You may need to restart your headset to see the zip file show up in the Downloads folder.");

The message already warns users about this issue, but it should be fixed.


🔍 Root Cause (Suspected)

Android's MediaStore is not being notified about the new file. The Quest Files app (and other file browsers) rely on the MediaStore database to list files. When files are written directly to storage without notifying the MediaStore, they won't appear until:

  • The headset restarts (triggers a media scan)
  • The MediaStore is manually refreshed

✅ Proposed Solution

Trigger a media scan after writing the file to notify Android's MediaStore:

private void ExecuteMoveToDownloads(string directoryName)
{
    try
    {
        // ... existing move code ...
        
        File.Move(zipPath, destZipPath);
        
        // NEW: Notify MediaStore about the new file
        #if UNITY_ANDROID && !UNITY_EDITOR
        ScanFile(destZipPath);
        #endif
        
        Debug.Log($"[{Constants.LOG_TAG}] RecordingOperations: Exported {directoryName} to {destZipPath}");
        OnOperationComplete?.Invoke("Export", true, $"Exported to Downloads: {Path.GetFileName(destZipPath)}");
    }
    catch (Exception e)
    {
        // ... error handling ...
    }
}

private void ScanFile(string filePath)
{
    #if UNITY_ANDROID && !UNITY_EDITOR
    try
    {
        using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
        using (AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext"))
        using (AndroidJavaClass mediaScanner = new AndroidJavaClass("android.media.MediaScannerConnection"))
        {
            mediaScanner.CallStatic("scanFile", context, new string[] { filePath }, null, null);
        }
        
        Debug.Log($"[{Constants.LOG_TAG}] Triggered media scan for: {filePath}");
    }
    catch (Exception e)
    {
        Debug.LogWarning($"[{Constants.LOG_TAG}] Failed to trigger media scan: {e.Message}");
    }
    #endif
}

✅ Acceptance Criteria

  • ZIP files appear immediately in Quest Files app after export completes
  • No restart required to see exported files
  • Update success message to remove restart warning

🧪 Testing

  1. Export a recording using "Export Data" button
  2. Wait for "Export complete" message
  3. Open Quest Files app
  4. Navigate to Downloads folder
  5. ✅ Verify ZIP file is visible immediately
  6. No restart needed

📚 References


🔗 Related Files

  • Assets/RealityLog/Scripts/Runtime/FileOperations/RecordingOperations.cs (lines 54-127, 277-320)
  • README.md (line 57) - mentions this known issue

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions