Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

Commit a5366af

Browse files
committed
Set modified date in EmbeddedFileProvider
1 parent 4ce656c commit a5366af

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/Microsoft.Extensions.FileProviders.Embedded/EmbeddedFileProvider.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,24 @@ public EmbeddedFileProvider(Assembly assembly, string baseNamespace)
4949

5050
_baseNamespace = string.IsNullOrEmpty(baseNamespace) ? string.Empty : baseNamespace + ".";
5151
_assembly = assembly;
52-
// REVIEW: Does this even make sense?
53-
_lastModified = DateTimeOffset.MaxValue;
52+
53+
_lastModified = DateTimeOffset.UtcNow;
54+
55+
#if NETSTANDARD1_5 || NET451
56+
if (!string.IsNullOrEmpty(_assembly.Location))
57+
{
58+
try
59+
{
60+
_lastModified = File.GetLastWriteTimeUtc(_assembly.Location);
61+
}
62+
catch (PathTooLongException)
63+
{
64+
}
65+
catch (UnauthorizedAccessException)
66+
{
67+
}
68+
}
69+
#endif
5470
}
5571

5672
/// <summary>

src/Microsoft.Extensions.FileProviders.Embedded/project.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@
2424
"version": "1.1.0-*",
2525
"type": "build"
2626
},
27-
"Microsoft.Extensions.FileProviders.Abstractions": "1.1.0-*"
27+
"Microsoft.Extensions.FileProviders.Abstractions": "1.1.0-*",
28+
"System.Runtime.Extensions": "4.1.0-*"
2829
},
2930
"frameworks": {
30-
"netstandard1.0": {
31+
// need to keep netstandard1.0 until ASP.NET Core 2.0 because it is a breaking change if we remove it
32+
"netstandard1.0": { },
33+
"netstandard1.5": {
3134
"dependencies": {
32-
"System.Runtime.Extensions": "4.1.0-*"
35+
"System.IO.FileSystem": "4.0.1-*",
36+
"System.Reflection": "4.1.0-*"
3337
}
34-
}
38+
},
39+
"net451": { }
3540
}
3641
}

0 commit comments

Comments
 (0)