diff --git a/navigator/components/NavFile.js b/navigator/components/NavFile.js index c40ecbb..e7a9d5a 100644 --- a/navigator/components/NavFile.js +++ b/navigator/components/NavFile.js @@ -20,7 +20,7 @@ import { NavEntry } from "./NavEntry.js"; import { NavDownloader } from "./NavDownloader.js"; import { NavWindow } from "./NavWindow.js"; -import { property_entry_html } from "../functions.js"; +import { property_entry_html, simple_spawn } from "../functions.js"; export class NavFile extends NavEntry { /** @@ -128,12 +128,9 @@ export class NavFile extends NavEntry { async write_to_file() { var new_contents = document.getElementById("nav-edit-contents-textarea").value; try { - if (new_contents.length) - await cockpit.file(this.path_str(), {superuser: "try"}).replace(new_contents); - else - await cockpit.script("echo -n > $1", [this.path_str()], {superuser: "try"}); + await simple_spawn(["/usr/share/cockpit/navigator/scripts/write-to-file.py3", this.path_str()], new_contents); } catch (e) { - this.nav_window_ref.modal_prompt.alert(e.message); + this.nav_window_ref.modal_prompt.alert(e); } this.nav_window_ref.refresh(); this.hide_edit_file_contents(); @@ -229,9 +226,9 @@ export class NavFileLink extends NavFile{ var target_path = this.get_link_target_path(); var new_contents = document.getElementById("nav-edit-contents-textarea").value; try { - await cockpit.file(target_path, {superuser: "try"}).replace(new_contents); + await simple_spawn(["/usr/share/cockpit/navigator/scripts/write-to-file.py3", target_path], new_contents); } catch (e) { - this.nav_window_ref.modal_prompt.alert(e.message); + this.nav_window_ref.modal_prompt.alert(e); } this.nav_window_ref.refresh(); this.hide_edit_file_contents();