-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in dev environments, override the file provider to use a fallback ima…
…ge for certain paths (#2062)
- Loading branch information
1 parent
129db21
commit 617784d
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.Extensions.FileProviders; | ||
using Microsoft.Extensions.Primitives; | ||
|
||
namespace TASVideos.Services; | ||
|
||
public class DevFallbackFileProvider(IFileProvider originalProvider) : IFileProvider | ||
{ | ||
public IDirectoryContents GetDirectoryContents(string subpath) | ||
{ | ||
return originalProvider.GetDirectoryContents(subpath); | ||
} | ||
|
||
public IFileInfo GetFileInfo(string subpath) | ||
{ | ||
IFileInfo fileInfo = originalProvider.GetFileInfo(subpath); | ||
if (!fileInfo.Exists && subpath.StartsWith("/media/")) | ||
{ | ||
return originalProvider.GetFileInfo("/images/tasvideos_rss.png"); | ||
} | ||
|
||
return fileInfo; | ||
} | ||
|
||
public IChangeToken Watch(string filter) | ||
{ | ||
return originalProvider.Watch(filter); | ||
} | ||
} |