Commit 2b4985ac authored by Michael Terry's avatar Michael Terry

Upgrade local folders to volumes if applicable

Helps when a user selects an internal or external drive from the
local folder chooser.

This way we also mount any internal drives selected (previously
we just treated them as always-mounted).

https://bugs.launchpad.net/deja-dup/+bug/1886730
parent 6b3e35d0
Pipeline #203093 passed with stage
in 4 minutes and 27 seconds
......@@ -249,14 +249,14 @@ public class ConfigLocationCombo : BuilderWidget
var self = (ConfigLocationCombo)data;
var id = variant.get_string();
if (id == "drive")
if (id == "drive") {
id = "drive:" + self.drive_settings.get_string(DejaDup.DRIVE_UUID_KEY);
if (!self.lookup_id(null, id, null))
self.add_saved_volume();
}
var found = self.lookup_id(null, id, null);
if (!found) {
// This is an old unsupported backend (un-plugged in drive will be
// handled already by add_saved_volume).
var label = id;
if (id == "gcs")
label = _("Google Cloud Storage");
......
......@@ -122,9 +122,14 @@ public class ConfigLocationGrid : BuilderWidget
}
if (dlg.run() == Gtk.ResponseType.ACCEPT) {
var path = DejaDup.BackendLocal.get_path_from_file(dlg.get_file());
if (path != null)
entry.text = path;
var file = dlg.get_file();
if (DejaDup.BackendDrive.set_volume_info_from_file(file, drive_settings)) {
settings.set_string(DejaDup.BACKEND_KEY, "drive");
} else {
var path = DejaDup.BackendLocal.get_path_from_file(file);
if (path != null)
entry.text = path;
}
}
}
......
......@@ -92,6 +92,31 @@ public class BackendDrive : BackendFile
}
}
// Return strue if path is a volume path and we changed settings
public static bool set_volume_info_from_file(File file, Settings settings)
{
Mount mount;
try {
mount = file.find_enclosing_mount();
} catch (Error e) {
return false;
}
var volume = mount.get_volume();
if (volume == null)
return false;
var folder = mount.get_root().get_relative_path(file);
settings.delay();
settings.set_string(DRIVE_UUID_KEY, volume.get_uuid());
settings.set_string(DRIVE_FOLDER_KEY, folder == null ? "" : folder);
update_volume_info(volume, settings);
settings.apply();
return true;
}
public static void update_volume_info(Volume volume, Settings settings)
{
var name = volume.get_name();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment