From: Domas Mituzas Date: Fri, 18 Feb 2005 19:30:14 +0000 (+0000) Subject: commit in working MogileFS upload code X-Git-Tag: 1.5.0alpha1~718 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=918dd66ec9d35889019bd83c5d28428aea5b0e01;p=lhc%2Fweb%2Fwiklou.git commit in working MogileFS upload code --- diff --git a/includes/SpecialUploadMogile.php b/includes/SpecialUploadMogile.php index 572e918b5c..20d53cdc20 100644 --- a/includes/SpecialUploadMogile.php +++ b/includes/SpecialUploadMogile.php @@ -9,7 +9,7 @@ * */ require_once( 'SpecialUpload.php' ); - +require_once( 'MogileFS.php' ); /** * Entry point @@ -35,25 +35,33 @@ class UploadFormMogile extends UploadForm { */ function saveUploadedFile( $saveName, $tempName, $useRename = false ) { global $wgUploadDirectory, $wgOut; + $mfs = MogileFS::NewMogileFS(); - $this->mSavedFile = "archive!{$saveName}"; + $this->mSavedFile = "image!{$saveName}"; - if( $mfs->getPaths( $this->mSavedFile ) ) { + if( $mfs->getPaths( $this->mSavedFile )) { $this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}"; - if( !$mfs->rename( $this->mSavedFile, "${archive}!{$this->mUploadOldVersion}" ) ) { + if( !$mfs->rename( $this->mSavedFile, "archive!{$this->mUploadOldVersion}" ) ) { $wgOut->fileRenameError( $this->mSavedFile, - "${archive}!{$this->mUploadOldVersion}" ); + "archive!{$this->mUploadOldVersion}" ); return false; } } else { $this->mUploadOldVersion = ''; } - if ( $mfs->saveFile($this->mSavedFile,'image',$tempName )) { - $wgOut->fileCopyError( $tempName, $this->mSavedFile ); - return false; + if ( $this->mStashed ) { + if (!$mfs->rename($tempName,$this->mSavedFile)) { + $wgOut->fileRenameError($tempName, $this->mSavedFile ); + return false; + } + } else { + if ( !$mfs->saveFile($this->mSavedFile,'normal',$tempName )) { + $wgOut->fileCopyError( $tempName, $this->mSavedFile ); + return false; + } + unlink($tempName); } - unlink($tempName); return true; } @@ -73,8 +81,8 @@ class UploadFormMogile extends UploadForm { global $wgOut; $stash = 'stash!' . gmdate( "YmdHis" ) . '!' . $saveName; - - if ( !$mfs->saveFile( $tempName, 'stash', $stash ) ) { + $mfs = MogileFS::NewMogileFS(); + if ( !$mfs->saveFile( $stash, 'normal', $tempName ) ) { $wgOut->fileCopyError( $tempName, $stash ); return false; } @@ -113,11 +121,11 @@ class UploadFormMogile extends UploadForm { * @access private */ function unsaveUploadedFile() { - if ( ! @$mfs->delete( $this->mUploadTempName ) ) { + global $wgOut; + $mfs = MogileFS::NewMogileFS(); + if ( ! $mfs->delete( $this->mUploadTempName ) ) { $wgOut->fileDeleteError( $this->mUploadTempName ); } } - - /* -------------------------------------------------------------- */ } ?>