Do not crash when file is not available
This commit is contained in:
parent
f98a149318
commit
4791b139b8
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Drawing;
|
|
||||||
using CliWrap;
|
using CliWrap;
|
||||||
using CliWrap.Buffered;
|
using CliWrap.Buffered;
|
||||||
using InnovEnergy.Lib.Utils;
|
using InnovEnergy.Lib.Utils;
|
||||||
|
@ -62,10 +61,20 @@ public class S3Cmd
|
||||||
return result.StandardOutput;
|
return result.StandardOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<String[]> GetFileText(String bucketName, String filename)
|
public async Task<IReadOnlyList<String>?> GetFileLines(String bucketName, String filename)
|
||||||
{
|
{
|
||||||
var result = await Run(bucketName + "/" + filename, "get", "--force");
|
try
|
||||||
return File.ReadAllLines("./" + filename);
|
{
|
||||||
|
await Run(bucketName + "/" + filename, "get", "--force");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lines = File.ReadAllLines($"./{filename}");
|
||||||
|
File.Delete(filename);
|
||||||
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Boolean> DeleteBucket(String bucketName)
|
public async Task<Boolean> DeleteBucket(String bucketName)
|
||||||
|
@ -76,7 +85,7 @@ public class S3Cmd
|
||||||
|
|
||||||
private Task<BufferedCommandResult> Run(String bucketName, String operation, params String[] optionalArgs)
|
private Task<BufferedCommandResult> Run(String bucketName, String operation, params String[] optionalArgs)
|
||||||
{
|
{
|
||||||
var credentials = new String[]
|
var credentials = new[]
|
||||||
{
|
{
|
||||||
S3CmdPath,
|
S3CmdPath,
|
||||||
"--access_key", Key,
|
"--access_key", Key,
|
||||||
|
|
Loading…
Reference in New Issue