WebDavServer icon indicating copy to clipboard operation
WebDavServer copied to clipboard

Read-Only FileSystem

Open MosheL opened this issue 6 years ago • 7 comments
trafficstars

Thanks for good product !

I am trying to make a read-only file system ,based on DotNetFileSystem but with a access list from database. this code works (the DNFS taking the list of files from SQL, and the files from the disk).

I tried to find the Options header list, on the source code, found all the HTTP Methods. I am trying to remove the COPY, MOVE, etc, but could not remove them, as they scan for IHandler without the option to disable it .

For now I was found this (ugly) way, but Windows is trying to update the files or create files like desktop.ini, and similar.

public async Task<Stream> CreateAsync(CancellationToken cancellationToken)        {
	throw new ArgumentException("cant write");
}

I tried also to rewrite the AddWebDav function, but its a ugly workaround.

How to implement a ReadOnly attr, so the client will recognise the status and will not try to modify/lock the files ?

MosheL avatar May 03 '19 11:05 MosheL

just to document a better ugly way:

services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.ICopyHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IMoveHandler )).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IDeleteHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IPutHandler )).First());
			

Windows still show the option to create files, but it did not try to create desktop.ini and its friends.

MosheL avatar May 03 '19 12:05 MosheL

I'm not sure if this is possible, because I couldn't find out whether MKCOL, etc.. are required for WebDAV 1 compliance.

fubar-coder avatar May 03 '19 14:05 fubar-coder

MKCOL is writing on objects, I understand right ?

thanks for all

MosheL avatar May 13 '19 10:05 MosheL

It's for creating a new collection (directory).

fubar-coder avatar May 13 '19 12:05 fubar-coder

I thought a bit about your problem. I guess the following solution would be what you really need:

  1. Remove the OptionsHandler (service IOptionsHandler)
  2. Register your own service returning only the HTTP methods that you want to allow

The allowed HTTP methods are returned in the Allow header.

EDIT: This allows returning a different Allow HTTP header per location.

fubar-coder avatar May 13 '19 14:05 fubar-coder

nice.

Thanks !

MosheL avatar May 14 '19 14:05 MosheL

Is this issue going to be solved?

I think your solution is to add a read-only implementation of IOptionsHandler. Am I right?

I'm not familiar with this. Is WebDavOptionsResult that contains Allow header? If so, is it better to use an Attribute or a property to indicate whether a filesystem is readonly?

Besides, I saw WebDavDispatcherClass1 and think this is where HTTP Allow header is set, but it seems this class is not used at all, which makes me confused.

BrandonStudio avatar Nov 16 '22 07:11 BrandonStudio