Skip to content

Commit

Permalink
整个仓库下面,直接跳转到目标Url,本地不做缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 6, 2024
1 parent 67db990 commit 60baa53
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion EasyWeb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ public async Task<ActionResult> DownloadFile(String pathInfo)
if (!System.IO.File.Exists(path))
{
// 直接跳转到原始地址
if (!entry.RawUrl.IsNullOrEmpty() && (entry.RawRedirect || entry.Parent != null && entry.Parent.RawRedirect))
if (!entry.RawUrl.IsNullOrEmpty() && (
entry.RawRedirect ||
entry.Parent != null && entry.Parent.RawRedirect ||
entry.Storage != null && entry.Storage.RawRedirect)
)
{
return Redirect(entry.RawUrl);
}
Expand Down
11 changes: 11 additions & 0 deletions EasyWeb/Entity/EasyFile.htm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ <h3>文件仓库(FileStorage)</h3>
<td>仅搜索匹配的文件,支持*,多个规则逗号隔开</td>
</tr>

<tr>
<td>RawRedirect</td>
<td>原始跳转</td>
<td>Boolean</td>
<td></td>
<td></td>
<td></td>
<td>N</td>
<td>跳转到原始地址</td>
</tr>

<tr>
<td>LastScan</td>
<td>最后扫描</td>
Expand Down
1 change: 1 addition & 0 deletions EasyWeb/Entity/Model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Column Name="Level" DataType="Int32" Description="深度。最大搜索目录深度" />
<Column Name="Period" DataType="Int32" Description="同步周期。默认60秒" />
<Column Name="Pattern" DataType="String" Description="匹配规则。仅搜索匹配的文件,支持*,多个规则逗号隔开" />
<Column Name="RawRedirect" DataType="Boolean" Description="原始跳转。跳转到原始地址" />
<Column Name="LastScan" DataType="DateTime" Description="最后扫描。记录最后一次扫描时间" />
<Column Name="CreateUserId" DataType="Int32" Description="创建者" Category="扩展" />
<Column Name="CreateTime" DataType="DateTime" Description="创建时间" Category="扩展" />
Expand Down
16 changes: 16 additions & 0 deletions EasyWeb/Entity/文件仓库.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public partial class FileStorage
[BindColumn("Pattern", "匹配规则。仅搜索匹配的文件,支持*,多个规则逗号隔开", "")]
public String Pattern { get => _Pattern; set { if (OnPropertyChanging("Pattern", value)) { _Pattern = value; OnPropertyChanged("Pattern"); } } }

private Boolean _RawRedirect;
/// <summary>原始跳转。跳转到原始地址</summary>
[DisplayName("原始跳转")]
[Description("原始跳转。跳转到原始地址")]
[DataObjectField(false, false, false, 0)]
[BindColumn("RawRedirect", "原始跳转。跳转到原始地址", "")]
public Boolean RawRedirect { get => _RawRedirect; set { if (OnPropertyChanging("RawRedirect", value)) { _RawRedirect = value; OnPropertyChanged("RawRedirect"); } } }

private DateTime _LastScan;
/// <summary>最后扫描。记录最后一次扫描时间</summary>
[DisplayName("最后扫描")]
Expand Down Expand Up @@ -183,6 +191,7 @@ public override Object this[String name]
"Level" => _Level,
"Period" => _Period,
"Pattern" => _Pattern,
"RawRedirect" => _RawRedirect,
"LastScan" => _LastScan,
"CreateUserId" => _CreateUserId,
"CreateTime" => _CreateTime,
Expand All @@ -206,6 +215,7 @@ public override Object this[String name]
case "Level": _Level = value.ToInt(); break;
case "Period": _Period = value.ToInt(); break;
case "Pattern": _Pattern = Convert.ToString(value); break;
case "RawRedirect": _RawRedirect = value.ToBoolean(); break;
case "LastScan": _LastScan = value.ToDateTime(); break;
case "CreateUserId": _CreateUserId = value.ToInt(); break;
case "CreateTime": _CreateTime = value.ToDateTime(); break;
Expand Down Expand Up @@ -254,6 +264,9 @@ public partial class _
/// <summary>匹配规则。仅搜索匹配的文件,支持*,多个规则逗号隔开</summary>
public static readonly Field Pattern = FindByName("Pattern");

/// <summary>原始跳转。跳转到原始地址</summary>
public static readonly Field RawRedirect = FindByName("RawRedirect");

/// <summary>最后扫描。记录最后一次扫描时间</summary>
public static readonly Field LastScan = FindByName("LastScan");

Expand Down Expand Up @@ -311,6 +324,9 @@ public partial class __
/// <summary>匹配规则。仅搜索匹配的文件,支持*,多个规则逗号隔开</summary>
public const String Pattern = "Pattern";

/// <summary>原始跳转。跳转到原始地址</summary>
public const String RawRedirect = "RawRedirect";

/// <summary>最后扫描。记录最后一次扫描时间</summary>
public const String LastScan = "LastScan";

Expand Down
2 changes: 2 additions & 0 deletions EasyWeb/Services/EntryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public async Task<Boolean> DownloadAsync(FileEntry entry, String path)
var url = entry.RawUrl;
if (url.IsNullOrEmpty()) return false;

using var span = _tracer?.NewSpan("DownloadFile", new { entry.Name, path, url });

XTrace.WriteLine("文件不存在,准备下载 {0} => {1}", url, path);

var client = new HttpClient();
Expand Down

0 comments on commit 60baa53

Please sign in to comment.