[Owncloud] Is it possible for a file's parent storage to be different from its own storage?

Robin Appelman icewind at owncloud.com
Tue Apr 30 23:07:59 UTC 2013


On Tuesday 30 April 2013 10:44:56 Sarah Jones wrote:
> On Mon, Apr 29, 2013 at 6:32 PM, Robin Appelman <icewind at owncloud.com>wrote:
> > On Monday 29 April 2013 15:23:39 Sarah Jones wrote:
> > > Hi,
> > > 
> > > I'm looking at the code in core lib/files/cache.cache.php.
> > > 
> > > For my app I need the storage string, and to cut everything before
> > > /data.
> > > 
> > >  I'm building a multiinstance owncloud app, so I cannot use "fileid"
> > >  from
> > > 
> > > filecache between instances; I'm using the storage and path as a key
> > > instead.
> > > However, if the storage string is more than 64 chars, the storageid is
> > > hashed, which makes this not possible.
> > > 
> > > I can work around this for the current file, but I need it's parent's
> > > storage as well.  Is it safe to assume that a child file and its parent
> > > will always have the same storageid?
> > > 
> > > Thanks,
> > > ~Sarah Jones
> > 
> > Using the cache alone it's not possible to get the parent storage, the
> > cache
> > holds no information about the context of a storage.
> > 
> > You can get the parent storage using information from the mount
> > configuration
> > by getting the full path of a file (getPath on either \OC\Files\Filesystem
> > or
> > \OC\Files\View), get the parent path and resolve that back to the cache
> > but
> > this is not always unqiue, if the same storage is mounted in different
> > places
> > it has multiple parent paths, this is one of the reason why we don't
> > storage
> > that information in the cache.
> > 
> >  - Robin Appelman
> 
> Hi Robin,
> 
> I'm not sure I understand your response.
> 
> This is my interpretation of the design: An entry in filecache has a
> parent, which is the fileid for another entry in the filecache.  Each
> filecache entry stores the storage numericId.  Using this information you
> can get the parent storage id string, but it may be a hash if the storage
> path was > 64 chars.

Correct

> Are you saying that yes it is possible for the storage of the parent
> filecache entry to be different from the storage of a filecache entry?

The parent relation in the filecache only goes within the same storage, there 
is no relation between 2 items from different storages in the cache, each 
storage is handled as a separate independent item in the cache.

If you have a storage mounted at /foo/bar, the cache entry for /foo/bar (or / 
from the storage's pov) will have no parent. It similar as mounted drives in a 
linux system, my /home parition isn't aware that it's mounted in /home.

Thus if you want the parent from the root of the root of a storage you'll need 
to use information from the mount configuration. However since a storage can be 
mounted at different places there is not always a unique parent. Just like I 
can mount my home drive at multiple places.

> And then the rest of your explanation is a suggestion of how I could get 
this
> information since they may not be the same?
> 
> Thanks,
> ~Sarah

 - Robin Appelman



More information about the Owncloud mailing list