FileSystem icon indicating copy to clipboard operation
FileSystem copied to clipboard

Make IFileSystem actions GetFileInfo, GetDirectoryContents async

Open Praburaj opened this issue 11 years ago • 14 comments

Praburaj avatar Dec 17 '14 21:12 Praburaj

@Praburaj I don't think that GetFileInfo will take much time, but i'm with you that GetDirectoryContents should be async

hishamco avatar Mar 21 '15 21:03 hishamco

:+1:

I am trying to implement Azure Blob storage on top for this and it would be great to have async methods. I also think that IFileInfo.Exists should be a Task<bool> returning method, not a property.

tugberkugurlu avatar Apr 26 '15 16:04 tugberkugurlu

@tugberkugurlu i don't think that the Exists property should be async

hishamco avatar Apr 26 '15 17:04 hishamco

@hishamco depends on the purpose of this abstraction library. In my case, I need to make an HTTP call to figure out if the resource exists, which is a perfect fit for async.

tugberkugurlu avatar Apr 26 '15 19:04 tugberkugurlu

@davidfowl do we want this?

muratg avatar May 06 '15 17:05 muratg

I don't think so. This isn't a generic file system abstraction. A blog storage implementation would be pretty weird.

davidfowl avatar May 06 '15 17:05 davidfowl

@davidfowl I'm agree with you what you said before, nothing but if we have a file system directory that contains nested directories and files, the GetDirectoryContentsAsync will be very helpful in such situation

hishamco avatar May 06 '15 20:05 hishamco

I guess I'm not sure why the FileSystem repository wouldn't be a generic (read-only) file system abstraction.

I'd also appreciate async on the file system methods. Instances off the top of my head where this might be relevant:

  • Network storage (whether NAS, SAN, Azure Blob Storage, or Amazon Cloud, or something more exotic)
  • Globbed files (compressed storage such that the directory tree is in a file)

In these instances, getting lists of files, existence of files, and getting file info could all benefit from being retrieved async. In cases where the async specification is not beneficial, a Task.FromResult would alleviate most implementation difficulties.

mdekrey avatar May 11 '15 17:05 mdekrey

:+1: for the asynt methods :)

luisrudge avatar May 22 '15 17:05 luisrudge

+1 would be nice to have this too, was just looking to see if I could do something for async file storage in Orchard 2

Jetski5822 avatar Nov 14 '16 09:11 Jetski5822

Minus 1 for Exists becoming a task :p - given that a fileinfo first has to be retrieved (via GetFileInfo or GetDirectoryContents) it seems you should know at that point - ahead of instantiating the FileInfo whether the requested file / directory exists or not.. imho.

I have also thought about an azure blob storage provider.. but I stopped when I thought about its Change Token implementation. It remains a crazy dream.

dazinator avatar Nov 19 '16 04:11 dazinator

I agree, Exists should stay non async

Jetski5822 avatar Nov 19 '16 04:11 Jetski5822

+1 for providing an async interface to IFileProvider. Since the configuration system is built on top of this we often have to make network calls to see if configs need to be refreshed. I love that this interface provides a Watch method for refreshing on changes but without the ability to make an async call to retrieve the file info it severely limits its usefulness.

lfoust avatar Mar 21 '17 16:03 lfoust

This issue was moved to aspnet/Home#2567

aspnet-hello avatar Jan 02 '18 00:01 aspnet-hello