Skip to content

Commit

Permalink
Merge pull request #7 from marvinweber/v1.1.1-develop
Browse files Browse the repository at this point in the history
Changes for Release v1.1.1
  • Loading branch information
marvinweber authored Sep 4, 2019
2 parents bbf714b + 5455321 commit 14fd198
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 114 deletions.
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

0 comments on commit 14fd198

Please sign in to comment.