fix: create OpenList target directories before verification
This commit is contained in:
@@ -123,6 +123,38 @@ public sealed class OpenListUploadTests
|
||||
Assert.Equal("/archive/主播", refreshedPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TryGetObject_TreatsMissingParentDuringRefreshAsCacheMiss()
|
||||
{
|
||||
var getCount = 0;
|
||||
var refreshedPath = string.Empty;
|
||||
var handler = new StubHttpMessageHandler(async request =>
|
||||
{
|
||||
if (request.RequestUri!.AbsolutePath.EndsWith("/api/auth/login", StringComparison.Ordinal))
|
||||
{
|
||||
return JsonResponse("""{"code":200,"message":"success","data":{"token":"test-token"}}""");
|
||||
}
|
||||
|
||||
var body = JsonDocument.Parse(await request.Content!.ReadAsStringAsync()).RootElement;
|
||||
if (request.RequestUri.AbsolutePath.EndsWith("/api/fs/list", StringComparison.Ordinal))
|
||||
{
|
||||
refreshedPath = body.GetProperty("path").GetString();
|
||||
return JsonResponse("""{"code":500,"message":"failed get objs: failed get dir: object not found","data":null}""");
|
||||
}
|
||||
|
||||
Assert.EndsWith("/api/fs/get", request.RequestUri.AbsolutePath, StringComparison.Ordinal);
|
||||
getCount++;
|
||||
return JsonResponse("""{"code":500,"message":"object not found","data":null}""");
|
||||
});
|
||||
var client = CreateClient(handler);
|
||||
|
||||
var result = await client.TryGetObjectAsync(Connection(), "/archive/新主播/2026-08-01/segment.mp4");
|
||||
|
||||
Assert.Null(result);
|
||||
Assert.Equal(1, getCount);
|
||||
Assert.Equal("/archive/新主播/2026-08-01", refreshedPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CopyAndTaskPolling_UseOpenListV423Contract()
|
||||
{
|
||||
@@ -313,6 +345,10 @@ public sealed class OpenListUploadTests
|
||||
Assert.Equal(twoGiB, job.VideoSizeBytes);
|
||||
Assert.True(await fixture.Queue.ProcessNextAsync());
|
||||
Assert.Equal([(job.SourceVideoPath, job.TargetVideoPath)], fixture.OpenList.CopyRequests);
|
||||
Assert.Equal(["/destination/Douyin/2026/08/01/主播"], fixture.OpenList.EnsuredDirectories);
|
||||
Assert.True(
|
||||
fixture.OpenList.Operations.IndexOf("ensure:/destination/Douyin/2026/08/01/主播") <
|
||||
fixture.OpenList.Operations.IndexOf($"get:{job.TargetVideoPath}"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -575,6 +611,10 @@ public sealed class OpenListUploadTests
|
||||
|
||||
public List<(string Source, string Target)> CopyRequests { get; } = [];
|
||||
|
||||
public List<string> EnsuredDirectories { get; } = [];
|
||||
|
||||
public List<string> Operations { get; } = [];
|
||||
|
||||
public OpenListCopyResult NextCopyResult { get; set; } = new([]);
|
||||
|
||||
public Task<OpenListConnectionTestDto> TestConnectionAsync(
|
||||
@@ -588,13 +628,21 @@ public sealed class OpenListUploadTests
|
||||
public Task EnsureDirectoryAsync(
|
||||
OpenListConnectionRequest connection,
|
||||
string path,
|
||||
CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
EnsuredDirectories.Add(path);
|
||||
Operations.Add($"ensure:{path}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<OpenListObjectInfo?> TryGetObjectAsync(
|
||||
OpenListConnectionRequest connection,
|
||||
string path,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
Task.FromResult(Objects.GetValueOrDefault(path));
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Operations.Add($"get:{path}");
|
||||
return Task.FromResult(Objects.GetValueOrDefault(path));
|
||||
}
|
||||
|
||||
public Task<OpenListCopyResult> CopyFileAsync(
|
||||
OpenListConnectionRequest connection,
|
||||
@@ -602,6 +650,7 @@ public sealed class OpenListUploadTests
|
||||
string targetPath,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Operations.Add($"copy:{sourcePath}->{targetPath}");
|
||||
CopyRequests.Add((sourcePath, targetPath));
|
||||
return Task.FromResult(NextCopyResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user