Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Agentew04 committed Sep 6, 2022
1 parent 14b8dec commit e326754
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ public static bool CheckHash(string password, string hash){
return BCrypt.Net.BCrypt.Verify(password, hash);
}


/// <summary>
/// Deletes a file in a secure way by overwriting it with
/// random garbage data n times.
/// </summary>
/// <param name="prog">The progessbar object, null if it's on a cli run</param>
/// <param name="filename">Full path of the file to be deleted</param>
public static void WipeFile(string filename, Progress? prog) {
bool verbose = prog is not null;
Expand Down Expand Up @@ -205,13 +207,13 @@ public static void WipeFile(string filename, Progress? prog) {
// Finally, delete the file
File.Delete(filename);

if(verbose) prog.Message(Message.LEVEL.DEBUG, $"{Path.GetFileName(filename)} cleared traces successfully");
prog?.Message(Message.LEVEL.DEBUG, $"{Path.GetFileName(filename)} cleared traces successfully");
}
catch(Exception e)
{
if(verbose) prog.Message(Message.LEVEL.ERROR, $"Error wiping file ({Path.GetFileName(filename)})" + e.Message);
catch(Exception e) {
if (verbose)
prog?.Message(Message.LEVEL.ERROR, $"Error wiping file ({Path.GetFileName(filename)})" + e.Message);
else
Utils.WriteLine("Error wiping file (" + Path.GetFileName(filename) + "): " + e.Message, ConsoleColor.Red);
WriteLine($"Error wiping file ({Path.GetFileName(filename)}): {e.Message}", ConsoleColor.Red);
}
}

Expand Down

0 comments on commit e326754

Please sign in to comment.