Hi all, I've setup a virtual file system using Sabredav which works great. I've got all the reads, writes, moves, auth etc working via the database however I'd like be able to do 2 more things, which I think are along the same lines:
1) In Windows when the drive is mounted using NetDrive, it shows used and total space on the drive icon. This by default is 1TB. I'd like to control this so I can set this to whatever space the user has. I've found {DAV:}quota-used-bytes & {DAV:}quota-available-bytes properties, but how can I set them? I assume they need set on the root node. 2) A user may only have read only access so I'd like to set all files and directories with a ro property. I currently have a check on each of the sabredav write functions (put, setName, delete etc) which returns a Forbidden Exception, however Windows doesn't handle it very quickly. If I can set each file as read only then windows should handle it better. The read only property I've found is {DAV:}isreadonly. Some example code so you can see the general structure. I've removed anything which isn't relevant. class virtualFile extends \Sabre\DAV\File { public $fileObj; function __construct($fileObj) { $this->fileObj = $fileObj; } function getName() { return $this->fileObj->originalFilename; } // call on an edit or file creation (after createFile) function put($data) { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } function get() { // [removed code]... } function getSize() { return $this->fileObj->fileSize; } function setName($newName) { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } function getContentType() { return $this->fileObj->fileType; } function getLastModified() { return strtotime($this->fileObj->uploadedDate); } public function getETag() { if (strlen($this->fileObj->fileHash)) { return '"' . time() . $this->fileObj->fileHash . '"'; } return null; } public function delete() { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } } class virtualCollection extends Sabre\DAV\Collection { public $folderObj; private $userId = null; function __construct($folderObj = null) { // [removed code]... } function getChildren() { // [removed code]... } function getFileChild($fileObj) { // [removed code]... } function getFolderChild($folderObj) { // [removed code]... } function createDirectory($folderName) { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } function getName() { return $this->folderObj->folderName; } function setName($newName) { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } function getLastModified() { return time(); } public function delete() { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } public function createFile($name, $data = null) { // check for rw access virtualWebdavHelper::checkUserHasWrite(); // [removed code]... } } // root node $rootNode = new \virtualCollection(null); // use our own object tree for better performance and data retention, i.e. for moves, copy etc. $virtualRootNode = new \virtualObjectTree($rootNode); // the rootNode needs to be passed to the server object $server = new DAV\Server($virtualRootNode); // create base url $url = 'www.someserver.com/dav/index.php'; // set base path $server->setBaseUri($url); // make sure there is a 'data' directory, writable by the server. This directory is used to store information about locks $lockBackend = new DAV\Locks\Backend\File('/tmp/data.dat'); $lockPlugin = new DAV\Locks\Plugin($lockBackend); $server->addPlugin($lockPlugin); // start $server->exec(); Thanks in advance, Red. -- You received this message because you are subscribed to the Google Groups "SabreDAV Discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to sabredav-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sabredav-discuss/d278d1f7-9ce6-44a4-a212-883842b57fa7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.