fix: create OpenList target directories before verification
This commit is contained in:
@@ -214,7 +214,11 @@ public sealed class OpenListClient : IOpenListClient
|
||||
// Cloud drivers can complete a server-side copy without invalidating
|
||||
// OpenList's directory cache. Refreshing the parent also makes files
|
||||
// written directly into a local mount visible before they are copied.
|
||||
await RefreshDirectoryAsync(connection, GetDirectoryName(path), cancellationToken);
|
||||
if (!await TryRefreshDirectoryAsync(connection, GetDirectoryName(path), cancellationToken))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await TryGetObjectCoreAsync(connection, path, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -267,7 +271,7 @@ public sealed class OpenListClient : IOpenListClient
|
||||
return new OpenListObjectInfo(name, size, isDirectory, hashes);
|
||||
}
|
||||
|
||||
private async Task RefreshDirectoryAsync(
|
||||
private async Task<bool> TryRefreshDirectoryAsync(
|
||||
OpenListConnectionRequest connection,
|
||||
string path,
|
||||
CancellationToken cancellationToken)
|
||||
@@ -279,7 +283,22 @@ public sealed class OpenListClient : IOpenListClient
|
||||
"/api/fs/list",
|
||||
new { path, password = string.Empty, refresh = true, page = 1, per_page = 0 }),
|
||||
cancellationToken);
|
||||
|
||||
if (envelope.Code == 200)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// OpenList commonly reports a missing directory as code 500 instead
|
||||
// of 404. A caller probing a not-yet-created target should still see
|
||||
// that as a normal cache miss.
|
||||
if (envelope.Code == 404 || ContainsAny(envelope.Message, "not found", "object not found", "no such file"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EnsureSuccess(envelope, $"OpenList refresh '{path}'");
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<OpenListCopyResult> CopyFileAsync(
|
||||
|
||||
@@ -375,6 +375,11 @@ public sealed class OpenListUploadQueueService
|
||||
return;
|
||||
}
|
||||
|
||||
// OpenList returns code 500 when refreshing a directory that does not
|
||||
// exist yet. Create the complete streamer/date hierarchy before the
|
||||
// first target probe so a new recording path can be uploaded normally.
|
||||
await _openListClient.EnsureDirectoryAsync(connection, GetDirectoryName(targetPath), cancellationToken);
|
||||
|
||||
var existingTarget = await VerifyTargetAsync(connection, targetPath, localPath, expectedSize, cancellationToken);
|
||||
if (existingTarget == TargetVerification.Match)
|
||||
{
|
||||
@@ -402,7 +407,6 @@ public sealed class OpenListUploadQueueService
|
||||
throw new InvalidOperationException($"OpenList 源文件大小不一致:期望 {expectedSize},实际 {sourceObject.Size},路径 {sourcePath}");
|
||||
}
|
||||
|
||||
await _openListClient.EnsureDirectoryAsync(connection, GetDirectoryName(targetPath), cancellationToken);
|
||||
var copyResult = await _openListClient.CopyFileAsync(connection, sourcePath, targetPath, cancellationToken);
|
||||
if (copyResult.TaskIds.Count == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user