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

Weitere Arbeit an safeReplace: Nicht nur das Loeschen wird jetzt mehr…

…fach versucht - auch das Umbenennen der Temp-Datei zurueck in die originale Datei.
  • Loading branch information...
willuhn committed Apr 6, 2016
1 parent 5d3ca6a commit 5753ef50acf5e1ebba42b41964d867f656f2053d
Showing with 22 additions and 2 deletions.
  1. +22 −2 src/org/kapott/hbci/passport/AbstractHBCIPassport.java
@@ -1057,11 +1057,31 @@ protected void safeReplace(File origFile, File tmpFile)
// Datei existiert immer noch, dann brauchen wir das Rename gar nicht erst versuchen
if (origFile.exists())
throw new HBCI_Exception("could not delete " + origFile);


// Das Rename versuchen wir jetzt auch wiederholt mehrfach
retry = 0;
HBCIUtils.log("renaming " + tmpFile.getName() + " to " + origFile.getName(), HBCIUtils.LOG_DEBUG);
if (!tmpFile.renameTo(origFile))
while (!tmpFile.renameTo(origFile) && retry++ < 20)
{
try
{
HBCIUtils.log("wait a little bit, maybe another thread (antivirus scanner) holds a lock, file still not renamed", HBCIUtils.LOG_WARN);
Thread.sleep(1000L);
}
catch (InterruptedException e)
{
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())
throw new HBCI_Exception("could not rename " + tmpFile.getName() + " to " + origFile.getName());
}
}

0 comments on commit 5753ef5

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