Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Beim sicheren Schreiben der Passport-Datei konnte die Warteschleife v…

…orzeitig beendet werden
  • Loading branch information...
willuhn committed Aug 2, 2016
1 parent 0fbac47 commit 84397df6e9ad0442173ca32f0afed37108afa299
Showing with 12 additions and 7 deletions.
  1. +12 −7 src/org/kapott/hbci/passport/AbstractHBCIPassport.java
@@ -1031,6 +1031,8 @@ public int getMaxGVSegsPerMsg()
*/
protected void safeReplace(File origFile, File tmpFile)
{
HBCIUtils.log("saving passport file " + origFile, HBCIUtils.LOG_INFO);

if (origFile.exists()) // Nur loeschen, wenn es ueberhaupt existiert
{
HBCIUtils.log("deleting old passport file " + origFile, HBCIUtils.LOG_DEBUG);
@@ -1066,8 +1068,17 @@ protected void safeReplace(File origFile, File tmpFile)
// Das Rename versuchen wir jetzt auch wiederholt mehrfach
retry = 0;
HBCIUtils.log("renaming " + tmpFile.getName() + " to " + origFile.getName(), HBCIUtils.LOG_DEBUG);
while (!tmpFile.renameTo(origFile) && retry++ < 20)
while (!origFile.exists() && retry++ < 20)
{
if (!tmpFile.renameTo(origFile))
HBCIUtils.log("rename method for " + tmpFile + " to " + origFile + " returned false", HBCIUtils.LOG_ERR);

if (origFile.exists())
{
HBCIUtils.log("new passport file now exists: " + origFile, HBCIUtils.LOG_DEBUG);
break;
}

try
{
HBCIUtils.log("wait a little bit, maybe another thread (antivirus scanner) holds a lock, file still not renamed", HBCIUtils.LOG_WARN);
@@ -1078,12 +1089,6 @@ protected void safeReplace(File origFile, File tmpFile)
HBCIUtils.log("interrupted", HBCIUtils.LOG_WARN);
break;
}
if (origFile.exists())
{
HBCIUtils.log("new passport file now exists: " + origFile, HBCIUtils.LOG_INFO);
break;
}
throw new HBCI_Exception("could not rename " + tmpFile.getName() + " to " + origFile.getName());
}

if (!origFile.exists())

0 comments on commit 84397df

Please sign in to comment.
You can’t perform that action at this time.