Use local-files api instead of download-manifest to detect existing files.

This commit is contained in:
ThatBen 2025-02-27 10:18:35 +01:00
parent 9b432ded46
commit 3ab1e2ea47
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
2 changed files with 16 additions and 4 deletions

View File

@ -40,7 +40,11 @@ namespace AutoClient.Modes.FolderStore
private void EnsureBasicCid()
{
if (IsBasicCidAvailable()) return;
if (IsBasicCidAvailable())
{
Log("BasicCid is available.");
return;
}
UploadFile();
}
@ -76,8 +80,14 @@ namespace AutoClient.Modes.FolderStore
{
try
{
var result = instance.Node.DownloadManifestOnly(new ContentId(entry.BasicCid));
return !string.IsNullOrEmpty(result.Cid.Id);
var result = instance.Node.LocalFiles();
if (result == null) return false;
if (result.Content == null) return false;
return result.Content.Any(c =>
c != null &&
c.Cid != null &&
!string.IsNullOrEmpty(c.Cid.Id) &&
c.Cid.Id.ToLowerInvariant() == entry.BasicCid.ToLowerInvariant());
}
catch
{
@ -88,6 +98,7 @@ namespace AutoClient.Modes.FolderStore
private void UploadFile()
{
Log("Uploading file...");
Changes = true;
try
{
@ -107,6 +118,7 @@ namespace AutoClient.Modes.FolderStore
private void CreateNewPurchase()
{
if (string.IsNullOrEmpty(entry.BasicCid)) return;
Log("Creating new purchase...");
Changes = true;
try

View File

@ -52,7 +52,7 @@ namespace AutoClient.Modes.FolderStore
}
statusFile.Save(status);
Thread.Sleep(2000);
Thread.Sleep(100);
}
}