dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

File.Exists returns true for non existing file (Azure Windows Web App) #52753

Open lampersky opened 3 years ago

lampersky commented 3 years ago

Description

I created few files (and directories) inside azure web app file system, with quite long names. Then I deleted directories and files.

File.Exists still returns True for non existing files, when I tried to delete them again I'm getting an exception. Other than that, I can't create files again this time getting Could not find a part of the path.

Here is a repro repo.

https://user-images.githubusercontent.com/6403130/118252822-77f5c400-b4a9-11eb-9d2e-91dd8569edae.mp4

This issue was first observed within Orchard Core.

Configuration

Regression?

I tried with both dotnetcore3.1 and net5.0, on both same issue.

Other information

App was deployed to azure using WebDeploy. After restarting webapp, files are not locked anymore, File.Exists returns relevant result.

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 3 years ago

Tagging subscribers to this area: @carlossanlop See info in area-owners.md if you want to be subscribed.

Issue Details
### Description I created few files (and directories) inside azure web app file system, with quite long names. Then I deleted directories and files. **File.Exists** still returns **True** for non existing files, when I tried to delete them again I'm getting an exception. Other than that, I can't create files again this time getting `Could not find a part of the path`. Here is a repro [repo](https://github.com/lampersky/PhysicalFileProviderRepro). https://user-images.githubusercontent.com/6403130/118252822-77f5c400-b4a9-11eb-9d2e-91dd8569edae.mp4 This issue was [first observed within Orchard Core](https://github.com/OrchardCMS/OrchardCore/issues/9319). ### Configuration * _Which version of .NET is the code running on?_ **dotnetcore3.1 net5.0** * _What OS and version, and what distro if applicable?_ **azure web app (windows)** * _What is the architecture (x64, x86, ARM, ARM64)?_ **I've only checked **x64**** * _Do you know whether it is specific to that configuration?_ **this can't be reproduced locally inside my Windows 10 environment** ### Regression? I tried with both **dotnetcore3.1** and **net5.0**, on both same issue. ### Other information App was deployed to azure using WebDeploy. After restarting **webapp**, files are not locked anymore, **File.Exists** returns relevant result.
Author: lampersky
Assignees: -
Labels: `area-System.IO`, `untriaged`
Milestone: -
jhudsoncedaron commented 3 years ago

Your PurgeAsync assumes that Root is ".".

lampersky commented 3 years ago

Your PurgeAsync assumes that Root is ".".

@jhudsoncedaron I'm not sure what do you mean.

MyFileProvider.PurgeAsync method simply iterates over all files and directories based on PhysicalFileProvider.GetDirectoryContents results.

MyFileProvider is configured as follows:

services.AddSingleton<IMyFileProvider>(serviceProvider =>
{
    var hostingEnvironment = serviceProvider.GetRequiredService<IWebHostEnvironment>();
    var root = $"{hostingEnvironment.WebRootPath}\\ms-cache\\Default";
    if (!Directory.Exists(root))
    {
        Directory.CreateDirectory(root);
    }
    return new MyFileProvider(root);
});

which means root (locally) is: image

lampersky commented 3 years ago

This issue can't be reproduced on azure free plan nor locally. So problem exists in paid plans.

davidfowl commented 3 years ago

cc @sebastienros

sebastienros commented 3 years ago

I provided a repro to the Antares team and they are investigating

adamsitnik commented 3 years ago

I provided a repro to the Antares team and they are investigating

@sebastienros any update on this?