I’m trying to mount an external location to my server. After mounting the location, I can create new files and folders, but getDirectoryListing() always returns an empty array. What am I doing wrong?
$arguments = [
'datadir' => '/mnt/sda1',
$storage = new \OC\Files\Storage\LocalRootStorage($arguments);
$mount = new \OC\Files\Mount\MountPoint($storage, '/sda1/', $arguments);//, $loader);
// This works and it DOES create the folder
// This always comes back with an empty array
// This throws an error
Lastly, I know that there are apps which allow mounting of external storage devices, but I am trying to do something a little different. This is just an example.
I am not sure, I get the point correctly, but you are trying to develop an app, am I right?
The reason I want to clarify this: If you are working on an app, you should consider the complete namespace prefix \OC as off-limits. It might change without further notification and break the app. Use the official \OCP namespace for whatever you want to achieve.
If you are working on the server code, please forget what I have written above. The complete opposite is more likely there. I cannot help there much, though.
Could you please explain, what your intention is? You just write you want to do it differently. In what sense?
Thanks for your reply, @christianlupus. This is code for the server core. I actually figured out a little more of this on my own and submitted a PR, but I still have a question that no one has answered:
Basically, I managed to create the mount, but I cannot write directly to the mount point and read back the files. I have to create a directory inside the mount and THEN create files inside of that new directory.
For example, say I create the mount point /appdata_[instanceid]. I can write files to that mount point, but I cannot read them back - they aren’t listed when I run getDirectoryListing(). The files DO exist on the filesystem, but the server cannot see them.
Instead, I have to create a directory inside the mount point like /appdata_[instanceid]/appdata_[instanceid]. Then, files can be written and read.
There seems to be some sort of permissions issue, but I’m not sure why. I tried using a permissions wrapper, but it didn’t make any difference. Any thoughts?