Thursday | 21 NOV 2024
[ previous ]
[ next ]

Thoughts on WebDAV and Partial Writes

Title:
Date: 2023-01-31
Tags:  

The current set up:

I have nginx set up with webdav such that I can GET and PUT a simple json file. In the frontend I parse the json and with that structure I can build out the application. When changes are made, the entire file is sent back to be saved.

The issue is that I don't want to send the entire file back for a small change.

I thought about instead of doing a single json file, each changeable item could be it's own separate file. This would solve the issue cleanly. Instead of saving the entire file, I save just the part that has changed. The issue with this idea is that now getting all the data requires many steps. I need to use PROPFIND to get a directory listing, then I need to loop through and do a GET request for each individual file.

I have thought about using sqlitefs and sqlite in the browser. This would allow me to use a sqlite database as the file system and now I can write items directly to the database. Then I can use sqlite in the browser to query the database for the information. I can do a SELECT statement which would presumably get me the ids and their contents.

The issue with this is that the sqlitefs project seems to implement a filesystem in sqlite rather than exposing sqlite as a filesystem. This distinction means that sqlite is holding all the file metadata and it has 2 tables it creates, one for the data and for the directory. This is a reverse of what I want. I want to create a table in sqlite that maps to a directory and then entries in that table should be files.

This idea is something that exists in UniVerse which is why I think something like it may exist for sqlite. In UniVerse, you can resize a table to type 19 and this would make it a linux file system. You can however also query it like a database from within UniVerse. This might only work because in Universe everything is a string.

I found a few different utilities but none work the way I want them to.

A Rust application:

https://github.com/narumatt/sqlitefs

Got it working but it is a filesystem in sqlite rather than exposing sqlite as a filesystem.

A Perl application:

https://github.com/kstep/fusqlfs

Got it working but can't make changes and it doesn't refresh to pick up changes made through sqlite.

A C application:

https://github.com/twopoint718/SQLiteFS

I never got this working but it wouldn't have worked, it makes tables into csv files and doesn't let you edit them.

I might need to write my own fuse driver for sqlite that does what I want it to, I think that is where things are currently at.