@@ -1224,9 +1224,22 @@ private function basicOperation(string $operation, string $path, array $hooks =
12241224 $ this ->removeUpdate ($ storage , $ internalPath );
12251225 }
12261226 if ($ result !== false && in_array ('write ' , $ hooks , true ) && $ operation !== 'fopen ' && $ operation !== 'touch ' ) {
1227- $ isCreateOperation = $ operation === 'mkdir ' || ($ operation === 'file_put_contents ' && in_array ('create ' , $ hooks , true ));
1228- $ sizeDifference = $ operation === 'mkdir ' ? 0 : $ result ;
1229- $ this ->writeUpdate ($ storage , $ internalPath , null , $ isCreateOperation ? $ sizeDifference : null );
1227+ if ($ operation === 'mkdir ' ) {
1228+ $ sizeDifference = 0 ;
1229+ } elseif ($ operation === 'file_put_contents ' ) {
1230+ if (in_array ('create ' , $ hooks , true )) {
1231+ $ sizeDifference = $ result ;
1232+ } elseif (in_array ('update ' , $ hooks , true )) {
1233+ $ cacheData = $ storage ->getCache ()->get ($ path );
1234+ $ sizeDifference = $ cacheData === false ? null : $ result - $ cacheData ->getSize ();
1235+ } else {
1236+ $ sizeDifference = null ;
1237+ }
1238+ } else {
1239+ $ sizeDifference = null ;
1240+ }
1241+
1242+ $ this ->writeUpdate ($ storage , $ internalPath , null , $ sizeDifference );
12301243 }
12311244 if ($ result !== false && in_array ('touch ' , $ hooks )) {
12321245 $ this ->writeUpdate ($ storage , $ internalPath , $ extraParam , 0 );
0 commit comments