Fixed some history issues in the new commands.
This commit is contained in:
parent
58494ddbcd
commit
1c1e6680c4
@ -174,17 +174,23 @@ public static class BaseModule
|
|||||||
{
|
{
|
||||||
action = delegate
|
action = delegate
|
||||||
{
|
{
|
||||||
if (!File.Exists(absDest))
|
if (File.Exists(absDest))
|
||||||
{
|
{
|
||||||
Write("Looks like the job is already completed Boss.", ConsoleColor.DarkYellow);
|
FileInfo info = new(absDest);
|
||||||
return;
|
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
||||||
|
throw new("The copied file has been modified and probably shouldn't be undone.");
|
||||||
|
|
||||||
|
File.Delete(absDest);
|
||||||
}
|
}
|
||||||
|
else if (Directory.Exists(absDest))
|
||||||
|
{
|
||||||
|
DirectoryInfo info = new(absDest);
|
||||||
|
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
||||||
|
throw new("The copied directory has been modified and probably shouldn't be undone.");
|
||||||
|
|
||||||
FileInfo info = new(absDest);
|
Directory.Delete(absDest, true);
|
||||||
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
}
|
||||||
throw new("The copied file or folder has been modified and probably shouldn't be undone.");
|
else Write("Looks like the job is already completed Boss.", ConsoleColor.DarkYellow);
|
||||||
|
|
||||||
File.Delete(absDest);
|
|
||||||
},
|
},
|
||||||
name = $"Copied a file or folder from \"{absSource}\" to \"{absDest}\""
|
name = $"Copied a file or folder from \"{absSource}\" to \"{absDest}\""
|
||||||
});
|
});
|
||||||
@ -340,17 +346,29 @@ public static class BaseModule
|
|||||||
{
|
{
|
||||||
action = delegate
|
action = delegate
|
||||||
{
|
{
|
||||||
if (!File.Exists(absDest))
|
if (File.Exists(absDest))
|
||||||
{
|
{
|
||||||
Write("Looks like the job is already completed Boss.", ConsoleColor.DarkYellow);
|
FileInfo info = new(absDest);
|
||||||
return;
|
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
||||||
|
throw new("The copied file has been modified and probably shouldn't be undone.");
|
||||||
|
|
||||||
|
if (File.Exists(absSource)) throw new($"A file already exists at {absSource} and can't " +
|
||||||
|
"be overriden.");
|
||||||
|
|
||||||
|
File.Move(absDest, absSource);
|
||||||
}
|
}
|
||||||
|
else if (Directory.Exists(absDest))
|
||||||
|
{
|
||||||
|
DirectoryInfo info = new(absDest);
|
||||||
|
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
||||||
|
throw new("The copied directory has been modified and probably shouldn't be undone.");
|
||||||
|
|
||||||
FileInfo info = new(absDest);
|
if (Directory.Exists(absSource)) throw new($"A directory already exists at {absSource} and " +
|
||||||
if ((info.LastWriteTime - stamp).TotalMilliseconds >= 10)
|
"can't be overriden.");
|
||||||
throw new("The moved file or folder has been modified and probably shouldn't be undone.");
|
|
||||||
|
|
||||||
File.Delete(absDest);
|
Directory.Move(absDest, absSource);
|
||||||
|
}
|
||||||
|
else Write("Looks like the job is already completed Boss.", ConsoleColor.DarkYellow);
|
||||||
},
|
},
|
||||||
name = $"Moved a file or folder from \"{absSource}\" to \"{absDest}\""
|
name = $"Moved a file or folder from \"{absSource}\" to \"{absDest}\""
|
||||||
});
|
});
|
||||||
@ -360,7 +378,7 @@ public static class BaseModule
|
|||||||
public static void ReallyDelete(string path)
|
public static void ReallyDelete(string path)
|
||||||
{
|
{
|
||||||
if (File.Exists(path)) File.Delete(path);
|
if (File.Exists(path)) File.Delete(path);
|
||||||
else if (Directory.Exists(path)) Directory.Delete(path);
|
else if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||||
else throw new($"No file or directory exists at \"{path}\"");
|
else throw new($"No file or directory exists at \"{path}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user