diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-03 01:24:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-07 00:41:32 +0100 |
| commit | e6119065337a8341955a38239d16267dc75c46c4 (patch) | |
| tree | 00c1e068e2cfa63fda75a9781a0d436a83a8aeaa /src/lib/cross_common.cc | |
| parent | a52ccd4da36f22b33934c75c8f1c15daba4b4c00 (diff) | |
Fix failure to unmount drives when one of their partitions is mounted (#2927).
Diffstat (limited to 'src/lib/cross_common.cc')
| -rw-r--r-- | src/lib/cross_common.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/cross_common.cc b/src/lib/cross_common.cc index 2e6f5c414..b6df88837 100644 --- a/src/lib/cross_common.cc +++ b/src/lib/cross_common.cc @@ -45,9 +45,13 @@ Drive::Drive (string xml) cxml::Document doc; doc.read_string (xml); _device = doc.string_child("Device"); +#ifdef DCPOMATIC_OSX + _mounted = doc.bool_child("Mounted"); +#else for (auto i: doc.node_children("MountPoint")) { _mount_points.push_back (i->content()); } +#endif _size = doc.number_child<uint64_t>("Size"); _vendor = doc.optional_string_child("Vendor"); _model = doc.optional_string_child("Model"); @@ -60,9 +64,13 @@ Drive::as_xml () const xmlpp::Document doc; auto root = doc.create_root_node ("Drive"); cxml::add_text_child(root, "Device", _device); +#ifdef DCPOMATIC_OSX + cxml::add_text_child(root, "Mounted", _mounted ? "1" : "0"); +#else for (auto i: _mount_points) { cxml::add_text_child(root, "MountPoint", i.string()); } +#endif cxml::add_text_child(root, "Size", fmt::to_string(_size)); if (_vendor) { cxml::add_text_child(root, "Vendor", *_vendor); @@ -86,13 +94,13 @@ Drive::description () const name += *_vendor; } if (_model) { - if (name.size() > 0) { + if (!name.empty()) { name += " " + *_model; } else { name = *_model; } } - if (name.size() == 0) { + if (name.empty()) { name = _("Unknown"); } @@ -104,14 +112,23 @@ string Drive::log_summary () const { string mp; +#ifdef DCPOMATIC_OSX + if (_mounted) { + mp += "mounted "; + } else { + mp += "not mounted "; + } +#else + mp = "mounted on "; for (auto i: _mount_points) { mp += i.string() + ","; } - if (mp.empty()) { + if (_mount_points.empty()) { mp = "[none]"; } else { mp = mp.substr (0, mp.length() - 1); } +#endif return String::compose( "Device %1 mounted on %2 size %3 vendor %4 model %5", |
