clean keep amount added to dest
This commit is contained in:
parent
190582b6dc
commit
64e4cb3c1a
|
@ -23,7 +23,7 @@ namespace MxB
|
|||
public bool inc { get; set; }
|
||||
}
|
||||
|
||||
public static string version = "1.5.0";
|
||||
public static string version = "1.6.0";
|
||||
public static string zipname = "";
|
||||
public static string zippath = "";
|
||||
static void Main(string[] args)
|
||||
|
@ -96,6 +96,7 @@ namespace MxB
|
|||
{
|
||||
int sc = j.source.Count;
|
||||
int scur = 1;
|
||||
if (!Directory.Exists($@"tmp\{j.name}")) { Directory.CreateDirectory($@"tmp\{j.name}"); }
|
||||
foreach (var js in j.source)
|
||||
{
|
||||
var sourceType = js.Split('|')[0];
|
||||
|
@ -106,7 +107,6 @@ namespace MxB
|
|||
if (sourceType == "F") { FileInfo fInfo = new FileInfo(sourcePath); sizeOfDir = FileSize(fInfo); }
|
||||
|
||||
Utilities.Message.CMW($"[{j.name}][{sourceType}][{((double)sizeOfDir) / (1024 * 1024):N2}MB]{scur}/{sc}] Processing...", true, 1);
|
||||
if (!Directory.Exists($@"tmp\{j.name}")) { Directory.CreateDirectory($@"tmp\{j.name}"); }
|
||||
switch (sourceType)
|
||||
{
|
||||
case "D":
|
||||
|
@ -130,18 +130,19 @@ namespace MxB
|
|||
}
|
||||
foreach (var dest in j.destination)
|
||||
{
|
||||
if (!Directory.Exists($@"{dest}\{j.name}")) { Directory.CreateDirectory($@"{dest}\{j.name}"); }
|
||||
var deststr = dest.Split('|')[1];
|
||||
if (!Directory.Exists($@"{deststr}\{j.name}")) { Directory.CreateDirectory($@"{deststr}\{j.name}"); }
|
||||
if (j.zip)
|
||||
{
|
||||
CreateZip(j.name, day, hour, lp);
|
||||
File.Copy($@"tmp\{j.name}-D{day}-H{hour}.zip", $@"{dest}\{j.name}\{j.name}-D{day}-H{hour}-M{minute}.zip");
|
||||
ClearFolder($@"tmp");
|
||||
File.Copy($@"tmp\{j.name}-D{day}-H{hour}.zip", $@"{deststr}\{j.name}\{j.name}-D{day}-H{hour}-M{minute}.zip");
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyFilesRecursively($@"tmp\{j.name}", dest, null);
|
||||
CopyFilesRecursively($@"tmp\{j.name}", deststr, null);
|
||||
}
|
||||
}
|
||||
ClearFolder($@"tmp");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,15 +150,15 @@ namespace MxB
|
|||
}
|
||||
} else if (args.Contains("--clean"))
|
||||
{
|
||||
int cc = Convert.ToInt32(args[2]);
|
||||
string jnarg = args[1];
|
||||
RootJobs j = JsonConvert.DeserializeObject<RootJobs>(File.ReadAllText($@"{lp}\jobs\{jnarg}.json"));
|
||||
Utilities.Message.CMW($"[{j.name}] Cleaning...", true, 1);
|
||||
foreach (var d in j.destination)
|
||||
{
|
||||
int destkeep = Convert.ToInt32(d.Split('|')[0]);
|
||||
var directory = new DirectoryInfo(d);
|
||||
var query = directory.GetFiles("*.zip", SearchOption.AllDirectories);
|
||||
foreach (var file in query.OrderBy(file => file.CreationTime).Skip(cc))
|
||||
foreach (var file in query.OrderByDescending(file => file.CreationTime).Skip(destkeep))
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue