In recordOldUpload, use source path when computing properties

During a file import, it's inefficient to upload the image to Swift and
then download it again to compute its properties. The arrangement
predates Swift -- it was efficient at the time. Instead, use the source
path which is always available.

Change-Id: I60dfb82f577479419ea663cd996738f1e90d5d3f
This commit is contained in:
Tim Starling 2021-06-08 09:19:56 +10:00 committed by Krinkle
parent 72137ddde1
commit e5993ea2db

View file

@ -463,16 +463,17 @@ class OldLocalFile extends LocalFile {
protected function recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) {
$dbw = $this->repo->getMasterDB();
$dstPath = $this->repo->getZonePath( 'public' ) . '/' . $this->getRel();
$props = $this->repo->getFileProps( $dstPath );
$services = MediaWikiServices::getInstance();
$mwProps = new MWFileProps( $services->getMimeAnalyzer() );
$props = $mwProps->getPropsFromPath( $srcPath, true );
if ( !$props['fileExists'] ) {
return false;
}
$this->setProps( $props );
$commentFields = MediaWikiServices::getInstance()->getCommentStore()
$commentFields = $services->getCommentStore()
->insert( $dbw, 'oi_description', $comment );
$actorId = MediaWikiServices::getInstance()->getActorNormalization()
$actorId = $services->getActorNormalization()
->acquireActorId( $user, $dbw );
$dbw->insert( 'oldimage',
[