Skip to content
Extraits de code Groupes Projets
Valider 69b05d49 rédigé par Thomas Goyne's avatar Thomas Goyne
Parcourir les fichiers

Retry commits of file writes for up to a second to work around AV scanning

Poorly-written antivirus software briefly lock newly written files to
scan them for viruses, which makes the rename from the temp file to
actual file fail. Work around this by retrying the rename up to ten
times.

Closes #1618.
parent 38dedfe1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -97,7 +97,22 @@ Save::Save(const std::string& file, bool binary)
Save::~Save() {
delete fp;
#ifndef _WIN32
util::Rename(tmp_name, file_name);
#else
for (int i = 0; i < 10; ++i) {
try {
util::Rename(tmp_name, file_name);
return;
}
catch (agi::FileNotAccessibleError const&) {
// Retry up to ten times in case it's just locked by a poorly-written antivirus scanner
if (i == 9)
throw;
Sleep(100);
}
}
#endif
}
std::ofstream& Save::Get() {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter