How to restrict editing files and folders

Hi, We have a requirement for locking files and folders. We’ll get a list of files and folders that has to be locked. We have to show icons for each of the locked files/folders. On opening a file, it should in read-only mode.
Things I tried:
I created the files/folders with different user modes, which the IDE process doesn’t have access.
With this, the user can edit but cannot save the file.

Appreciate any help here.

[original thread by vizay08]

Can you resolve on system level by having different users with different access level?

You can try to resolve it on UI level, but there are always ways to work it around like using terminals or running a task.

I’m not sure how Theia is good at recognising such attributes and prohibiting modifications via UI. If it does not please file a bug, but at the end Theia will call some system API and if a user starting Theia does not have access it won’t work.


Hi Anton,I did use different system levels and disabled terminal and the tasks. For having the custom icons in the File Navgator, found the Label.*Contribution to override. I couldn’t figure out the contribution for disabling the edits.

Please file an issue we need to implement in Theia properly as well.

You will need to custoimze FileResourceResolver and delete save methods from FileResource which don’t have write access:

its used to determine whether an editor is readonly: