Skip to content

Commit

Permalink
File/Folder validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-s committed Feb 18, 2021
1 parent 0761aec commit f1812fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/QnapBackupDecryptor.Core/JobMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ public static class JobMaker

public static List<FileJob> GetDecryptJobs(string encryptedSource, string decryptedTarget, bool overwrite, bool includeSubFolders)
{
if (Directory.Exists(encryptedSource) == false & File.Exists(encryptedSource) == false)
return new List<FileJob> { new FileJob(new DirectoryInfo(encryptedSource), new FileInfo(decryptedTarget), false, "Source does not exist") };

var sourceIsFolder = File.GetAttributes(encryptedSource).HasFlag(FileAttributes.Directory);
var destIsFolder = File.GetAttributes(decryptedTarget).HasFlag(FileAttributes.Directory);

bool destIsFolder = false;
if (Directory.Exists(decryptedTarget))
destIsFolder = File.GetAttributes(decryptedTarget).HasFlag(FileAttributes.Directory);

if (sourceIsFolder & destIsFolder == false)
return new List<FileJob> { new FileJob(new DirectoryInfo(encryptedSource), new FileInfo(decryptedTarget), false, "Cannot write an encrypted folder to a single file") };
Expand Down

0 comments on commit f1812fa

Please sign in to comment.