File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -891,7 +891,7 @@ public function calculateFolderSize($path, $entry = null) {
891891 return (int )$ row ['unencrypted_size ' ];
892892 }, $ rows );
893893 $ unencryptedSizes = array_map (function (array $ row ) {
894- return (int )(($ row ['unencrypted_size ' ] > 0 ) ? $ row ['unencrypted_size ' ]: $ row ['size ' ]);
894+ return (int )(($ row ['unencrypted_size ' ] > 0 ) ? $ row ['unencrypted_size ' ] : $ row ['size ' ]);
895895 }, $ rows );
896896
897897 $ sum = array_sum ($ sizes );
@@ -913,18 +913,22 @@ public function calculateFolderSize($path, $entry = null) {
913913 } else {
914914 $ unencryptedTotal = $ unencryptedSum ;
915915 }
916- if ($ entry ['size ' ] !== $ totalSize ) {
917- // only set unencrypted size for a folder if any child entries have it set
918- if ($ unencryptedMax > 0 ) {
919- $ this ->update ($ id , [
920- 'size ' => $ totalSize ,
921- 'unencrypted_size ' => $ unencryptedTotal ,
922- ]);
923- } else {
924- $ this ->update ($ id , [
925- 'size ' => $ totalSize ,
926- ]);
927- }
916+ } else {
917+ $ totalSize = 0 ;
918+ $ unencryptedTotal = 0 ;
919+ $ unencryptedMax = 0 ;
920+ }
921+ if ($ entry ['size ' ] !== $ totalSize ) {
922+ // only set unencrypted size for a folder if any child entries have it set, or the folder is empty
923+ if ($ unencryptedMax > 0 || $ totalSize === 0 ) {
924+ $ this ->update ($ id , [
925+ 'size ' => $ totalSize ,
926+ 'unencrypted_size ' => $ unencryptedTotal ,
927+ ]);
928+ } else {
929+ $ this ->update ($ id , [
930+ 'size ' => $ totalSize ,
931+ ]);
928932 }
929933 }
930934 }
You can’t perform that action at this time.
0 commit comments