trannamtrung1st / elFinder.Net.Core

An elFinder backend connector with less magic code and more compatibility. This enables .NET Standard 2.0 projects to easily integrate elFinder functionalities.
Apache License 2.0
12 stars 8 forks source link

All volume files and folders to be readonly and locked, except for uploads folder #18

Closed huwjeffries closed 2 years ago

huwjeffries commented 2 years ago

Hi there, I'd all files and folders in a volume to be locked and readonly, EXCEPT for a special "uploads" folder in each volume. I don't think it's currently possible to configure it that way? The root volume folder can only be set to locked & readonly by setting volume.IsLocked = true, volume.IsReadOnly = true. These setting override any ObjectAttributes I set for child folders due to code like this in IDirectoryExtensions and IFileExtensions:

objAttr.Write = volume.IsReadOnly ? false : objAttr.Write; objAttr.Locked = volume.IsLocked ? true : objAttr.Locked; objAttr.ShowOnly = volume.IsShowOnly ? true : objAttr.ShowOnly;

Would it be worth adding an additional property to Volume to specify that volume.IsReadOnly, etc, only applies to the root folder and not to child folders? Another approach would be to allow ObjectAttributes to trump volume settings, but that might break the contract for existing users.

PS - Thanks for your excellent work on this project - it's a lot better designed than the original elFinder.NetCore.

trannamtrung1st commented 2 years ago

Hi @huwjeffries , thanks for pointing this out. I choose your second approach which is allowing the ObjectAttributes to override the volume settings. It's simple and reasonable as well. You can review the changes here. I also put a warning for people about the changes so I think it will not be a big deal. https://github.com/trannamtrung1st/elFinder.Net.Core/releases/tag/all-1.3.5 PS - Very appreciate your compliments, thank you.

huwjeffries commented 2 years ago

Thanks for your speedy reply! You could maybe add this use case to the advanced demo code when you have time so that people can see how it can be configured.