Skip to content

Commit

Permalink
storage: Stop/start btrfs monitor around dialog actions
Browse files Browse the repository at this point in the history
In Anaconda mode.  This removes any interference from private mounts
during those dialog actions.
  • Loading branch information
mvollmer committed Jan 15, 2025
1 parent be6daaa commit c613e5c
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions pkg/storaged/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ const client = {

cockpit.event_target(client);

client.run = (func) => {
const prom = func();
if (prom) {
client.busy += 1;
return prom.finally(() => {
client.busy -= 1;
client.dispatchEvent("changed");
});
}
client.run = async (func) => {
if (client.in_anaconda_mode())
await client.btrfs_stop_monitoring();
const prom = func() || Promise.resolve();
client.busy += 1;
await prom.finally(() => {
client.busy -= 1;
btrfs_start_monitor();
client.dispatchEvent("changed");
});
};

/* Superuser
Expand Down Expand Up @@ -344,11 +345,18 @@ export async function btrfs_poll() {
btrfs_update(data);
}

let btrfs_monitor_channel = null;

function btrfs_start_monitor() {
if (!client.superuser.allowed || !client.features.btrfs) {
return;
}

if (btrfs_monitor_channel)
return;

console.log("STARTING");

const channel = python.spawn(btrfs_tool_py, ["monitor", ...btrfs_poll_options()], { superuser: "require" });
let buf = "";

Expand All @@ -365,6 +373,22 @@ function btrfs_start_monitor() {
channel.catch(err => {
throw new Error(err.toString());
});

btrfs_monitor_channel = channel;
}

client.btrfs_stop_monitoring = () => {
if (btrfs_monitor_channel) {
console.log("STOPPING");
const res = btrfs_monitor_channel.then(() => {
console.log("(stopped)");
btrfs_monitor_channel = null;
});
btrfs_monitor_channel.close();
return res;
} else {
return Promise.resolve();
}
}

function btrfs_start_polling() {
Expand Down

0 comments on commit c613e5c

Please sign in to comment.