Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for Release v1.1.1 #7

Merged
merged 3 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions KPSimpleBackup/KPSimpleBackup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override string UpdateUrl
{
get
{
return "https://raw.githubusercontent.com/weberonede/KPSimpleBackup/master/kpsimplebackup.version";
return "https://raw.githubusercontent.com/marvinweber/KPSimpleBackup/master/kpsimplebackup.version";
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ private void BackupAction(PwDatabase database)
String dateTimeFormat = this.m_config.DateFormat;
string time = DateTime.Now.ToString(dateTimeFormat);

// Save backup database for each specified path
// Save backup database for each specified path and perform cleanup
foreach (String backupFolderPath in paths)
{
string dbBackupFileName = this.GetBackupFileName(database);
Expand All @@ -127,7 +127,7 @@ private void BackupAction(PwDatabase database)
database.SaveAs(connection, false, null);

// Cleanup
this.Cleanup(backupFolderPath, dbBackupFileName);
this.Cleanup(backupFolderPath, dbBackupFileName, database.IOConnectionInfo.Path);
}
}

Expand All @@ -146,20 +146,26 @@ private String GetBackupFileName(PwDatabase database)
return backupFileName;
}

private void Cleanup(String path, String fileNamePrefix)
private void Cleanup(String path, String fileNamePrefix, String originalDatabasePath)
{
int filesToKeepAmount = (int)this.m_config.FileAmountToKeep;
// read from settings wether to use recycle bin or delete files permanently
int filesToKeepAmount = (int) this.m_config.FileAmountToKeep;
// read from settings whether to use recycle bin or delete files permanently
var recycleOption = this.m_config.UseRecycleBinDeletedBackups ? RecycleOption.SendToRecycleBin : RecycleOption.DeletePermanently;

String searchPattern = fileNamePrefix + "*" + ".kdbx";
String searchPattern = fileNamePrefix + "_*.kdbx";
String[] fileList = Directory.GetFiles(path, searchPattern).OrderBy(f => f).Reverse().ToArray();

// if more backup files available than needed loop through the unnecessary ones and remove them
if (fileList.Count() > filesToKeepAmount)
{
for (int i = filesToKeepAmount; i < fileList.Count(); i++)
{
// never delete original file -> always skip it (in case it made it in the filelist)
if (fileList[i].Equals(originalDatabasePath))
{
continue;
}

FileSystem.DeleteFile(fileList[i], UIOption.OnlyErrorDialogs, recycleOption);
}
}
Expand Down
4 changes: 2 additions & 2 deletions KPSimpleBackup/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: NeutralResourcesLanguage("en")]

Loading