@@ -77,15 +77,30 @@ public static function generate(Configuration $configuration, string $configurat
77
77
$ fileName .= (is_string ($ file ->contents ) && strpos ($ file ->contents , '<?php ' ) === false ? '' : '.php ' );
78
78
$ fileContents = $ fileStringyfier ->toString ($ file );
79
79
$ fileContentsHash = md5 ($ fileContents );
80
- try {
81
- /** @phpstan-ignore-next-line */
82
- @mkdir (dirname ($ fileName ), 0744 , true );
83
- } catch (FilesystemException ) {
84
- // @ignoreException
80
+
81
+ if (
82
+ ! $ state ->generatedFiles ->has ($ fileName ) ||
83
+ $ state ->generatedFiles ->get ($ fileName )->hash !== $ fileContentsHash
84
+ ) {
85
+ try {
86
+ /** @phpstan-ignore-next-line */
87
+ @mkdir (dirname ($ fileName ), 0744 , true );
88
+ } catch (FilesystemException ) {
89
+ // @ignoreException
90
+ }
91
+
92
+ file_put_contents ($ fileName , $ fileContents );
93
+ $ state ->generatedFiles ->upsert ($ fileName , $ fileContentsHash );
94
+
95
+ while (! file_exists ($ fileName ) || $ fileContentsHash !== md5 (file_get_contents ($ fileName ))) {
96
+ usleep (100 );
97
+ }
85
98
}
86
99
87
- file_put_contents ($ fileName , $ fileContents );
88
- $ state ->generatedFiles ->upsert ($ fileName , $ fileContentsHash );
100
+ $ existingFiles = array_filter (
101
+ $ existingFiles ,
102
+ static fn (string $ file ): bool => $ file !== $ fileName ,
103
+ );
89
104
90
105
if ($ file ->loadOnWrite === \OpenAPITools \Utils \File::DO_NOT_LOAD_ON_WRITE ) {
91
106
continue ;
0 commit comments