Feature request: FileExists() and FolderExists() for IStorageProvider

Topics: Core, General
Developer
Apr 24, 2012 at 5:01 PM

Frankly this is driving me nuts, most of my code using files gets ugly and error-prone because there is no possibility to check the existence of entities with IStorageProvider. I've already opened an issue for this and there is also a closely related issue. The aim for "Orchard Future Versions" means almost never however, and I'm very sad that according to this in the foreseeable future such a fundamental feature will remain missing.

I've already implemented FileExists() and FolderExists() with the default FileSystemStorageProvider in a fork (complete with tests) and also submitted a pull request for that on 15 December but it wasn't evaluated till now.

It's an issue that including this change would prose an interface change, thus a breaking change. There are a handful of modules implementing IStorageProvider (Bitrac.SMEStorageProvider, there should be one for Azure and if I remember correctly there is one for Amazon cloud) already, but module authors could be notified now, months before the 1.5 release. Also every storage solution should have some sort of existence check, so implementing the two methods would only be a matter of calling some lower-level API methods.

Please say something, this gets more and more frustrating.

Coordinator
Apr 24, 2012 at 6:01 PM

Sorry for the frustration, and thanks for providing the code. We're reevaluating this for 1.5.

Developer
Apr 24, 2012 at 8:22 PM

Thanks, I'm looking forward to it!

Developer
Apr 24, 2012 at 8:57 PM

Just wanted to +1 the proposed features. I came across this need before as well.

May 21, 2012 at 2:06 PM

+1! We'd also like to have this functionality added.

Also, in the methods ListFiles() and ListFolders(), why aren't we using .EnumerateFiles() and .EnumerateFolders(), respectively, on the DirectoryInfo object? Calling code could be run much more efficiently on folders with a large amount of files/subfolders.