Skip to content

Commit

Permalink
fix: improve network filesystem handling and error reporting in volum…
Browse files Browse the repository at this point in the history
…e metadata
  • Loading branch information
mceachen committed Dec 16, 2024
1 parent f2ce764 commit 3e58972
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/darwin/volume_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ class GetVolumeMetadataWorker : public MetadataWorkerBase {
void GetDiskArbitrationInfo() {
DEBUG_LOG("[GetVolumeMetadataWorker] Getting Disk Arbitration info for: %s",
mountPoint.c_str());

// Check if this is a network filesystem
if (metadata.fstype == "smbfs" || metadata.fstype == "nfs" ||
metadata.fstype == "afpfs" || metadata.fstype == "webdav") {
// For network filesystems, we consider them healthy even without DA info
metadata.remote = true;
metadata.status = "healthy";
return;
}

CFReleaser<DASessionRef> session(DASessionCreate(kCFAllocatorDefault));
if (!session.isValid()) {
DEBUG_LOG("[GetVolumeMetadataWorker] Failed to create DA session");
Expand Down Expand Up @@ -249,19 +259,25 @@ class GetVolumeMetadataWorker : public MetadataWorkerBase {
DEBUG_LOG("[GetVolumeMetadataWorker] Processing network volume");
CFBooleanRef isNetworkVolume = (CFBooleanRef)CFDictionaryGetValue(
description, kDADiskDescriptionVolumeNetworkKey);

metadata.remote = CFBooleanGetValue(isNetworkVolume);

CFURLRef url = (CFURLRef)CFDictionaryGetValue(
description, kDADiskDescriptionVolumePathKey);
if (!url) {
metadata.error = "Invalid URL";
return;
}

CFStringRef urlString = CFURLGetString(url);
if (!urlString) {
CFReleaser<CFStringRef> urlString(
CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle));
if (!urlString.isValid()) {
metadata.error = std::string("Invalid URL string: ") +
CFStringToString(urlString.get());
return;
}
metadata.uri = CFStringToString(urlString);

DEBUG_LOG("[GetVolumeMetadataWorker] URL path: %s",
CFStringToString(urlString.get()).c_str());
metadata.uri = CFStringToString(urlString.get());
}
};

Expand Down

0 comments on commit 3e58972

Please sign in to comment.