writes overview CID to file
This commit is contained in:
parent
f18ff24bb6
commit
e91a574b2c
|
@ -70,7 +70,8 @@ namespace AutoClient
|
|||
try
|
||||
{
|
||||
var cid = await codex.UploadFile(file);
|
||||
return await codex.RequestStorage(cid);
|
||||
var response = await codex.RequestStorage(cid);
|
||||
return response.PurchaseId;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace AutoClient
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<string> RequestStorage(ContentId cid)
|
||||
public async Task<RequestStorageResult> RequestStorage(ContentId cid)
|
||||
{
|
||||
app.Log.Debug("Requesting storage for " + cid.Id);
|
||||
var result = await codex.Codex.CreateStorageRequestAsync(cid.Id, new StorageRequestCreation()
|
||||
|
@ -101,7 +101,24 @@ namespace AutoClient
|
|||
var encoded = await GetEncodedCid(result);
|
||||
app.CidRepo.AddEncoded(cid.Id, encoded);
|
||||
|
||||
return result;
|
||||
return new RequestStorageResult(result, new ContentId(encoded));
|
||||
}
|
||||
|
||||
public class RequestStorageResult
|
||||
{
|
||||
public RequestStorageResult(string purchaseId, ContentId encodedCid)
|
||||
{
|
||||
PurchaseId = purchaseId;
|
||||
EncodedCid = encodedCid;
|
||||
}
|
||||
|
||||
public string PurchaseId { get; }
|
||||
public ContentId EncodedCid { get; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{PurchaseId} (cid: {EncodedCid})";
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<StoragePurchase?> GetStoragePurchase(string pid)
|
||||
|
|
|
@ -186,25 +186,26 @@ namespace AutoClient.Modes.FolderStore
|
|||
|
||||
Log($"Creating new purchase...");
|
||||
var response = await codex.RequestStorage(new CodexPlugin.ContentId(State.Cid));
|
||||
if (string.IsNullOrEmpty(response) ||
|
||||
response == "Unable to encode manifest" ||
|
||||
response == "Purchasing not available" ||
|
||||
response == "Expiry required" ||
|
||||
response == "Expiry needs to be in future" ||
|
||||
response == "Expiry has to be before the request's end (now + duration)")
|
||||
var purchaseId = response.PurchaseId;
|
||||
if (string.IsNullOrEmpty(purchaseId) ||
|
||||
purchaseId == "Unable to encode manifest" ||
|
||||
purchaseId == "Purchasing not available" ||
|
||||
purchaseId == "Expiry required" ||
|
||||
purchaseId == "Expiry needs to be in future" ||
|
||||
purchaseId == "Expiry has to be before the request's end (now + duration)")
|
||||
{
|
||||
throw new InvalidOperationException(response);
|
||||
throw new InvalidOperationException(purchaseId);
|
||||
}
|
||||
|
||||
var newPurchase = new WorkerPurchase
|
||||
{
|
||||
Created = DateTime.UtcNow,
|
||||
Pid = response
|
||||
Pid = purchaseId
|
||||
};
|
||||
State.Purchases = State.Purchases.Concat([newPurchase]).ToArray();
|
||||
SaveState();
|
||||
|
||||
Log($"New purchase created. PID: '{response}'. Waiting for submit...");
|
||||
Log($"New purchase created. PID: '{purchaseId}'. Waiting for submit...");
|
||||
Thread.Sleep(500);
|
||||
onNewPurchase();
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ namespace AutoClient.Modes.FolderStore
|
|||
Log("Requesting storage for it...");
|
||||
var result = await codex.RequestStorage(cid);
|
||||
Log("Storage requested. Purchase ID: " + result);
|
||||
|
||||
var outFile = Path.Combine(app.Config.DataPath, "OverviewZip.cid");
|
||||
File.WriteAllLines(outFile, [DateTime.UtcNow.ToString("o") + " - " + result.EncodedCid.Id]);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue