Get directories/folders and files from a specific path in RavenFS

98 views
Skip to first unread message

marcus

unread,
Sep 16, 2014, 10:56:50 AM9/16/14
to rav...@googlegroups.com
Is it possible to get all files and folders from a specific path eg. images/?

Federico Lois

unread,
Sep 16, 2014, 12:41:40 PM9/16/14
to rav...@googlegroups.com
Yes. You can use OnDirectory in it's recursive or non recursive form.

Federico

Sent from my mobile phone

From: marcus
Sent: ‎16/‎09/‎2014 11:56
To: rav...@googlegroups.com
Subject: [RavenDB] Get directories/folders and files from a specific path inRavenFS

Is it possible to get all files and folders from a specific path eg. images/?

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

marcus

unread,
Sep 16, 2014, 1:00:08 PM9/16/14
to rav...@googlegroups.com
If I have two files and one "sub directory" in "images/" and query like this session.Query().OnDirectory("images/").ToListAsync() I only get the two items, the two files not the sub directory? The expected result would be 2 files and one directory, three items instead of two.

Federico Lois

unread,
Sep 16, 2014, 1:23:57 PM9/16/14
to rav...@googlegroups.com
Directories do not have an entity inside the FileSystem, just files. However, I am interested to know what you want to achieve, because right now there is no high-level handling API for directories.

We can issue directories searches from the low level API but they are mostly used for supporting the high-level files api.

Kijana Woodard

unread,
Sep 16, 2014, 1:28:04 PM9/16/14
to rav...@googlegroups.com
Given the gmail vs hotmail design, why would one want _a_ directory when you could use tags and have n "directories".

marcus

unread,
Sep 16, 2014, 1:31:36 PM9/16/14
to rav...@googlegroups.com
I'm implementing IFileSystem in ASP.NET vNext and if you look att Microsofts example here https://github.com/aspnet/FileSystem/blob/dev/src/Microsoft.AspNet.FileSystems/PhysicalFileSystem.cs#L155 you can see that they are returning "directories" as well.

Kijana Woodard

unread,
Sep 16, 2014, 1:34:13 PM9/16/14
to rav...@googlegroups.com
I'm not following. That's an implementation detail. You don't need to actually use "paths".

Imagine an IFileSystem implementation that just used a dictionary.

marcus

unread,
Sep 16, 2014, 1:44:16 PM9/16/14
to rav...@googlegroups.com
Yeah sure it is, but do you think it's odd that I'm thinking of folders in RavenFS as directories in my implementation of IFileSystem? I could use some metadata like tags or whatever but I don't think that it would make any sense at all.

Kijana Woodard

unread,
Sep 16, 2014, 2:04:34 PM9/16/14
to rav...@googlegroups.com
I haven't looked at RavenFS enough to comment. I would *hope* that one could build "directories" from some kind of tag system such that I can have one file in, say 100 "folders".

Federico Lois

unread,
Sep 16, 2014, 2:11:29 PM9/16/14
to rav...@googlegroups.com
@Kijana as I see there the difference in interpretation in RavenFS and IFileSystem is that directories are treated as first class citizens in IFileSystem but they are not in RavenFS. That concept of 

For example:
/// <summary>
/// True for the case TryGetDirectoryContents has enumerated a sub-directory
/// </summary>
bool IsDirectory get; }
@marcus You may be able to have an empty directory. In RavenFS empty directories do not exist. You either have a file and therefore a containing directory (root or whatever) or you don't. You can still implement it though with the low level API. 

On the Command interface, you have a call that will return you all the subdirectories of a particular directory (if you ask the root you will get the entire directory structure).
Task<string[]> GetDirectoriesAsync(string from = nullint start = 0, int pageSize = 1024);
@A file in multiple directories is more like a file with tags, so using metadata you have that. You probably would use folders as containers to physically separate stuff (if you need to) but there is no reason why you must use them anyways. 

Kijana Woodard

unread,
Sep 16, 2014, 3:21:36 PM9/16/14
to rav...@googlegroups.com
Is the metadata atomic or eventually consistent to queries?

If I create a file with metadata "xyz" and immediately issue a query for files with "xyz", is the file just added guaranteed to be in the result?

Oren Eini (Ayende Rahien)

unread,
Sep 16, 2014, 3:33:15 PM9/16/14
to ravendb
That depend on your impl.
You have path, for the file. 
We build virtual directory from paths.
But you can have a metadata for the file and say that it belong to multiple parent "directories", too.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811



Reply all
Reply to author
Forward
0 new messages