From 374a3a07a1373161ceae7fa975eafdee66dbfeaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 30 Jun 2022 17:28:42 +0200 Subject: [PATCH] libtracker: don't try to fix permissions on read-only volumes * instead try to guess the type, find the app, and launch the app with the document refs. * fix #5783 Change-Id: Icd25a81ff28038fec0494045390edc6271433b07 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5425 Reviewed-by: waddlesplash --- src/kits/tracker/FSUtils.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 27b5689721..5ab526299a 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -2463,7 +2463,7 @@ FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl, if (status != B_OK) return status; - (*_runningSize) += statbuf.st_blocks* 512; + (*_runningSize) += statbuf.st_blocks * 512; if (S_ISDIR(statbuf.st_mode)) { BDirectory subdir(&entry); @@ -3583,6 +3583,24 @@ _TrackerLaunchDocuments(const entry_ref*, const BMessage* refs, error = B_OK; if (error == B_OK || mimesetIt != 0) break; + if (error == B_LAUNCH_FAILED_EXECUTABLE) { + BVolume volume(documentRef.device); + if (volume.IsReadOnly()) { + BMimeType type; + error = BMimeType::GuessMimeType(&documentRef, &type); + if (error != B_OK) + break; + error = be_roster->FindApp(type.Type(), &app); + if (error != B_OK) + break; + error = be_roster->Launch(&app, refs, &team); + if (error == B_ALREADY_RUNNING) + // app already running, not really an error + error = B_OK; + if (error == B_OK || mimesetIt != 0) + break; + } + } SniffIfGeneric(©OfRefs); }