Skip to content

Commit

Permalink
[prefab] savePrefabDat retries writing file if exception occured
Browse files Browse the repository at this point in the history
EspeuteClement committed Jan 20, 2025
1 parent 3099ea3 commit ab52302
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion hide/prefab/ContextShared.hx
Original file line number Diff line number Diff line change
@@ -91,7 +91,23 @@ class ContextShared extends hrt.prefab.ContextShared.ContextSharedBase {
}
return;
}else{
sys.io.File.saveBytes(file, bytes);
final numRetries = 5;
var success = false;
var lastError = null;
for (i in 0...numRetries) {
try {
sys.io.File.saveBytes(file, bytes);
success = true;
break;
} catch (e) {
lastError = e;
Sys.sleep(0.1);
continue;
}
}
if (!success) {
throw lastError;
}
}
}

0 comments on commit ab52302

Please sign in to comment.