Skip to content

Fix do not copy file source permissions#188

Closed
onny wants to merge 1 commit intoworkbenchdev:mainfrom
onny:source-perms-fix
Closed

Fix do not copy file source permissions#188
onny wants to merge 1 commit intoworkbenchdev:mainfrom
onny:source-perms-fix

Conversation

@onny
Copy link

@onny onny commented Feb 11, 2023

Hey,
following fix helped us to package and use Workbench on NixOS. The patch was made by hqurve , see original comment:

And I think it's because the app tries to copy $out/share/re.sonny.Workbench/workbench-api.vala to ~/.local/share/re.sonny.Workbench/workbench.vala on start, but files in Nix store has a 444 mode so it fails at the second run:

By searching the source for "workspace.vala", I determined that the file copy is performed at https://github.com/sonnyp/Workbench/blob/v43.3/src/langs/vala/vala.js#L13. By looking at the GIO api for the copy function, we can use the G_FILE_COPY_TARGET_DEFAULT_PERMS flag to "Leave target file with default perms, instead of setting the source file perms."

I applied the following patch and rebuilt workbench. After clearing the ~/.local/share/re.sonnyp.Workbench directory, reopening worked

From b5862ec862a1e9a4b01b09f3ca341e57999353c3 Mon Sep 17 00:00:00 2001
From: hqurve <[email protected]>
Date: Wed, 8 Feb 2023 07:31:04 -0400
Subject: [PATCH] do not copy source perms

---
 src/langs/vala/vala.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/langs/vala/vala.js b/src/langs/vala/vala.js
index e5ccfcc..dc0b25b 100644
--- a/src/langs/vala/vala.js
+++ b/src/langs/vala/vala.js
@@ -12,7 +12,7 @@ export function setup({ data_dir, document }) {
 
   api_file.copy(
     Gio.File.new_for_path(data_dir).get_child("workbench.vala"),
-    Gio.FileCopyFlags.OVERWRITE,
+    Gio.FileCopyFlags.OVERWRITE | Gio.FileCopyFlags.TARGET_DEFAULT_PERMS,
     null,
     null,
   );
-- 
2.39.1

I assume that flags work using bits. Also, you probably want to reword the commit message.

Also, by searching the code for copy(, I think this is the only instance of copying files

This patch propably doesn't affect any other users of Workbench but would help us to solve this issue on NixOS.

Best regards
Jonas

@onny onny mentioned this pull request Feb 11, 2023
13 tasks
@sonnyp
Copy link
Contributor

sonnyp commented Feb 11, 2023

EDIT: comment moved to NixOS/nixpkgs#208866 (comment)

@sonnyp
Copy link
Contributor

sonnyp commented Mar 6, 2023

I will be closing this for now. Workbench only supports Flatpak.
Next Workbench version will exit if not run as a Flatpak.

If someone is willing to invest time into making Workbench work as intended (sandboxed and with a specific target env) outside of Flatpak - feel free to open an issue.

@sonnyp sonnyp closed this Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants