#1284 "Overwrite if Newer and apply deletions" no longer working correctly v2.27

KeePass_2.x
closed
nobody
None
5
2015-05-04
2014-09-01
Mark Bee
No

I have two Keepass KDBX (2.x) databases and master and a mini, the mini is a copy of the master with many entries that not required removed, so the entries in the mini have the same UUID as the entries in the master.

I open the master and then import the mini using 'Overwrite if Newer and apply deletions' it no longer deletes the entries from the master.

I used this function regular previously but seemed to stop working in v2.27 also finding that KPscript no longer work like it used to.

Discussion

  • Dominik Reichl

    Dominik Reichl - 2014-09-02
    • status: open --> closed
     
  • Dominik Reichl

    Dominik Reichl - 2014-09-02

    I've tested this, but cannot reproduce the issue. The 'Overwrite if newer and apply deletions' mode works as expected.

    If you still think that there's something wrong, please post a sample database and detailed steps what you're doing.

    Best regards,
    Dominik

     
  • Mark Bee

    Mark Bee - 2015-05-04

    Thanks for looking at the problem.
    I did indeed produce a script which I then used test multiple scenario's of mashing together two simple files; A.kdbx and B.kdbx for version 2.9

    I did find some bugs around folder names in some cases not being as expected.
    I must say I went to some lengths to document it all but sent an undeclared variable into a remove-item command with a wildcard and .. well ... most of it got deleted by accident.

    Still here is the basis of the Powershell script I used, I hope it may be of use to you

    function read-kdbx {
    param( $type, $currentscenario, $file )
    
        $StartProcess = New-Object System.Diagnostics.ProcessStartInfo
        $StartProcess.FileName = "$KPScriptLocation"
        $StartProcess.RedirectStandardOutput = $true
        $StartProcess.UseShellExecute = $false
        $StartProcess.Arguments = "$type ""$resultsfolder\$currentscenario\$file"" -pw:a"
        $Process = New-Object System.Diagnostics.Process
        $Process.StartInfo = $StartProcess
        $Process.Start() | Out-Null
        $Process.WaitForExit()
    
        $output = $Process.StandardOutput.ReadToEnd()
    
        remove-item "$swap\*" -Recurse -Force
    
        $i2 = 0
        $i3 = 0
        $script:element = @{}
    
        $rawoutput = $output.Split("`n")
    
        foreach ($line in $rawoutput) {
    
        $line = $line.Trim()
        if ($line -match "UUID") { $i2 ++ }
        if ($line -match "=") {  $line = $line.Substring(3) }
        else { $line = $line.Replace(": "," = ")}
        if (($line -ne "") -and (!($line -match "OK")))  { Add-content ("$swap\$i2.txt") ($line) }
        }
    
        Do {
            $i3 ++
            $content = [System.IO.File]::ReadAllText("$swap\$i3.txt")
            $script:element[$i3] = convertfrom-stringdata -stringdata  $content
    
        } until ($i3 -eq $i2)
    
        return
    
    }
    
    function report-element {
                # medium report
                #Add-Content $resultsfile "Entry Name: $($Script:element[$count].Title)    UUID: $($Script:element[$count].UUID)"
                #Add-Content $resultsfile "Password: $($Script:element[$count].Password)   Group Name: $($Script:element[$count].GRPN)"
                #Add-Content $resultsfile " "
    
                # one liner
                Add-Content $resultsfile "Entry Name: $($Script:element[$count].Title)    UUID: $($Script:element[$count].UUID)   Password: $($Script:element[$count].Password)   Group Name: $($Script:element[$count].GRPN)"
    
    }
    
    $rootresultsfolder = "C:\keepass_testing\results\RESULTS $((Get-Date).DayOfWeek) $((Get-Date).Day) $(get-date -Format MMMM) $(get-date -Format hh-mm)"
    $KPScriptLocation = "C:\Program Files (x86)\KeePass Password Safe 2\KPScript.exe"
    $source = "C:\Keepass_Testing\source"
    $swap = "C:\Keepass_Testing\results\swap"
    # remove-item "C:\Keepass_Testing\results\*" -Recurse -Force
    New-Item $swap -type directory
    
    $MM = "","-MM:CreateNewUuids","-MM:KeepExisting","-MM:OverwriteExisting","-MM:OverwriteIfNewer","-MM:Sync"
    
    $scenariodescriptions = @(
                            "scenario 1: Only the folders have changed name",
                            "scenario 2: 'B' contains the SAME entries with DIFFERENT names",
                            "scenario 3: 'B' contains two NEW entries with the SAME names",
                            "scenario 4: 'B' contains two NEW entries with DIFFERENT names",
                            "scenario 5: 'B' has an additional entry",
                            "scenario 6: 'B' has an entry deleted",
                            "scenario 7: 'A' contains different entry names",
                            "scenario 8 : 'B' one entry deleted, then one entry created using the SAME name.",
                            "scenario 9 : 'B' one entry deleted, then one entry created using the DIFFERENT name.",
                            "scenario 10 : 'B' entries are deleted and left in the recycle bin",
                            "scenario 11 : 'A' entries are deleted and left in the recycle bin" )
    
    #Add-Content $resultsfile " "
    #Add-Content $resultsfile " "
    #Add-Content $resultsfile "Kpscript Import Testing"
    #Add-Content $resultsfile "Using Keepass version 2.29"
    #Add-Content $resultsfile "Created by mark bee (mark@beemail.me.uk)"
    #Add-Content $resultsfile " "
    #Add-Content $resultsfile " "
    
    foreach ($synctype in $MM) {
    
        $filefrendly = $synctype.replace("-MM:","")
        $resultsfolder = "$rootresultsfolder\Testing import type '$filefrendly'"
        New-Item $resultsfolder -type directory
        $resultsfile = "$resultsfolder\results for type '$filefrendly'.txt"
    
        Add-Content $resultsfile "=============================================="
        Add-Content $resultsfile " TESTING THE BEHAVIOUR OF SYNC TYPE '$synctype'"
        Add-Content $resultsfile "=============================================="
    
        #remove-item "C:\Keepass_Testing\refreshed_data\*" -Recurse -Force
        Copy-Item -Path "$source\*" -Destination $resultsfolder -Recurse
    
        $i1 = 1 
        do { 
    
            $currentscenario = "scenario$i1"
            Add-Content $resultsfile " "
            Add-Content $resultsfile " "
            Add-Content $resultsfile "------------------------------------------------------------------------------------------"
            Add-Content $resultsfile $scenariodescriptions[$i1-1]
            Add-Content $resultsfile "------------------------------------------------------------------------------------------"
            Add-Content $resultsfile " "
            Add-Content $resultsfile " ----- Contents of file A.kdbx BEFORE the action"
            read-kdbx -type "-c:ListEntries" -currentscenario $currentscenario -file "A.kdbx"
            $count = 0
            do { $count ++ ; report-element } until ($count -eq $element.count)
    
            Add-Content $resultsfile " ----- Contents of file B.kdbx BEFORE the action"
            read-kdbx -type "-c:ListEntries" -currentscenario $currentscenario -file "B.kdbx"
            $count = 0
            do { $count ++ ; report-element } until ($count -eq $element.count)
    
            Add-Content $resultsfile " "
            Add-Content $resultsfile "*******************"
            Add-Content $resultsfile "PROCESSING THE FILE: " #using import sync type '$synctype'"
            Start-Process -FilePath "$KPScriptLocation" -ArgumentList "-c:Import ""$resultsfolder\$currentscenario\A.kdbx"" -File:""$resultsfolder\$currentscenario\B.kdbx"" -pw:a -Format:""KeePass KDBX (2.x)"" $synctype"
            Add-Content $resultsfile "*******************"
            Add-Content $resultsfile " "
    
            Start-Sleep -Seconds 3
    
            Add-Content $resultsfile " ----- Contents of file A.kdbx AFTER the action"
            read-kdbx -type "-c:ListEntries" -currentscenario $currentscenario -file "A.kdbx"
            $count = 0
            do { $count ++ ; report-element } until ($count -eq $element.count)
    
            Add-Content $resultsfile " ----- Contents of file B.kdbx AFTER the action"
            read-kdbx -type "-c:ListEntries" -currentscenario $currentscenario -file "B.kdbx"
            $count = 0
            do { $count ++ ; report-element } until ($count -eq $element.count)
    
            $i1 ++
        } 
    
        until ( $i1 -gt $scenariodescriptions.count)
    
    }
    
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks