| Index: trunk/phase3/maintenance/dumpTextPass.php |
| — | — | @@ -308,7 +308,7 @@ |
| 309 | 309 | $fileinfo = pathinfo($filenameList[$i]); |
| 310 | 310 | $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn; |
| 311 | 311 | } |
| 312 | | - $this->egress->rename( $newFilenames ); |
| | 312 | + $this->egress->closeAndRename( $newFilenames ); |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | xml_parser_free( $parser ); |
| Index: trunk/phase3/includes/Export.php |
| — | — | @@ -704,6 +704,10 @@ |
| 705 | 705 | return; |
| 706 | 706 | } |
| 707 | 707 | |
| | 708 | + function closeAndRename( $newname ) { |
| | 709 | + return; |
| | 710 | + } |
| | 711 | + |
| 708 | 712 | function rename( $newname ) { |
| 709 | 713 | return; |
| 710 | 714 | } |
| — | — | @@ -752,6 +756,21 @@ |
| 753 | 757 | } |
| 754 | 758 | } |
| 755 | 759 | |
| | 760 | + function closeAndRename( $newname ) { |
| | 761 | + if ( is_array($newname) ) { |
| | 762 | + if (count($newname) > 1) { |
| | 763 | + throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n"); |
| | 764 | + } |
| | 765 | + else { |
| | 766 | + $newname = $newname[0]; |
| | 767 | + } |
| | 768 | + } |
| | 769 | + if ( $newname ) { |
| | 770 | + fclose( $this->handle ); |
| | 771 | + rename( $this->filename, $newname ); |
| | 772 | + } |
| | 773 | + } |
| | 774 | + |
| 756 | 775 | function rename( $newname ) { |
| 757 | 776 | if ( is_array($newname) ) { |
| 758 | 777 | if (count($newname) > 1) { |
| — | — | @@ -784,11 +803,21 @@ |
| 785 | 804 | if ( !is_null( $file ) ) { |
| 786 | 805 | $command .= " > " . wfEscapeShellArg( $file ); |
| 787 | 806 | } |
| 788 | | - $this->handle = popen( $command, "w" ); |
| | 807 | + |
| | 808 | + $this->startCommand($command); |
| 789 | 809 | $this->command = $command; |
| 790 | 810 | $this->filename = $file; |
| 791 | 811 | } |
| 792 | 812 | |
| | 813 | + function startCommand($command) { |
| | 814 | + $spec = array( |
| | 815 | + 0 => array( "pipe", "r" ), |
| | 816 | + ); |
| | 817 | + $pipes = array(); |
| | 818 | + $this->procOpenResource = proc_open( $command, $spec, $pipes ); |
| | 819 | + $this->handle = $pipes[0]; |
| | 820 | + } |
| | 821 | + |
| 793 | 822 | /** |
| 794 | 823 | * Close the old file, move it to a specified name, |
| 795 | 824 | * and reopen new file with the old name. |
| — | — | @@ -803,14 +832,32 @@ |
| 804 | 833 | } |
| 805 | 834 | } |
| 806 | 835 | if ( $newname ) { |
| 807 | | - pclose( $this->handle ); |
| | 836 | + fclose( $this->handle ); |
| | 837 | + proc_close($this->procOpenResource); |
| 808 | 838 | rename( $this->filename, $newname ); |
| 809 | 839 | $command = $this->command; |
| 810 | 840 | $command .= " > " . wfEscapeShellArg( $this->filename ); |
| 811 | | - $this->handle = popen( $command, "w" ); |
| | 841 | + $this->startCommand($command); |
| 812 | 842 | } |
| 813 | 843 | } |
| 814 | 844 | |
| | 845 | + function closeAndRename( $newname ) { |
| | 846 | + if ( is_array($newname) ) { |
| | 847 | + if (count($newname) > 1) { |
| | 848 | + throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n"); |
| | 849 | + } |
| | 850 | + else { |
| | 851 | + $newname = $newname[0]; |
| | 852 | + } |
| | 853 | + } |
| | 854 | + if ( $newname ) { |
| | 855 | +# pclose( $this->handle ); |
| | 856 | + fclose( $this->handle ); |
| | 857 | + proc_close($this->procOpenResource); |
| | 858 | + rename( $this->filename, $newname ); |
| | 859 | + } |
| | 860 | + } |
| | 861 | + |
| 815 | 862 | function rename( $newname ) { |
| 816 | 863 | if ( is_array($newname) ) { |
| 817 | 864 | if (count($newname) > 1) { |
| — | — | @@ -872,14 +919,31 @@ |
| 873 | 920 | } |
| 874 | 921 | } |
| 875 | 922 | if ( $newname ) { |
| 876 | | - pclose( $this->handle ); |
| | 923 | + fclose( $this->handle ); |
| | 924 | + proc_close($this->procOpenResource); |
| 877 | 925 | rename( $this->filename, $newname ); |
| 878 | 926 | $command = "7za a -bd -si " . wfEscapeShellArg( $file ); |
| 879 | 927 | $command .= ' >' . wfGetNull() . ' 2>&1'; |
| 880 | | - $this->handle = popen( $command, "w" ); |
| | 928 | + $this->startCommand($command); |
| 881 | 929 | } |
| 882 | 930 | } |
| 883 | 931 | |
| | 932 | + function closeAndRename( $newname ) { |
| | 933 | + if ( is_array($newname) ) { |
| | 934 | + if (count($newname) > 1) { |
| | 935 | + throw new MWException("Export closeRenameAndReopen: passed multiple argumnts for rename of single file\n"); |
| | 936 | + } |
| | 937 | + else { |
| | 938 | + $newname = $newname[0]; |
| | 939 | + } |
| | 940 | + } |
| | 941 | + if ( $newname ) { |
| | 942 | + fclose( $this->handle ); |
| | 943 | + proc_close($this->procOpenResource); |
| | 944 | + rename( $this->filename, $newname ); |
| | 945 | + } |
| | 946 | + } |
| | 947 | + |
| 884 | 948 | function rename( $newname ) { |
| 885 | 949 | if ( is_array($newname) ) { |
| 886 | 950 | if (count($newname) > 1) { |
| — | — | @@ -944,6 +1008,10 @@ |
| 945 | 1009 | $this->sink->closeRenameAndReopen( $newname ); |
| 946 | 1010 | } |
| 947 | 1011 | |
| | 1012 | + function closeAndRename( $newname ) { |
| | 1013 | + $this->sink->closeAndRename( $newname ); |
| | 1014 | + } |
| | 1015 | + |
| 948 | 1016 | function rename( $newname ) { |
| 949 | 1017 | $this->sink->rename( $newname ); |
| 950 | 1018 | } |
| — | — | @@ -1106,6 +1174,11 @@ |
| 1107 | 1175 | } |
| 1108 | 1176 | } |
| 1109 | 1177 | |
| | 1178 | + function closeAndRename( $newname ) { |
| | 1179 | + for( $i = 0; $i < $this->count; $i++ ) { |
| | 1180 | + $this->sinks[$i]->closeAndRename( $newnames[$i] ); |
| | 1181 | + } |
| | 1182 | + } |
| 1110 | 1183 | function rename( $newnames ) { |
| 1111 | 1184 | for( $i = 0; $i < $this->count; $i++ ) { |
| 1112 | 1185 | $this->sinks[$i]->rename( $newnames[$i] ); |