1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Kick off indexing for File objects on creation

Summary: Ensures that newly-made `File` objects get indexed into the new ngrams index. Fixes T8788.

Test Plan:
  - uploaded a file with daemons stopped; confirmed no new rows in ngrams table
  - started daemons; confirmed indexing of previously-uploaded files happened
  - uploaded a new file with daemons running; confirmed it got added to the index

Not sure how to test the changes to `PhabricatorFileUploadSource->writeChunkedFile()` and `PhabricatorChunkedFileStorageEngine->allocateChunks()`. I spent a few minutes trying to find their callers, but the first looks like it requires a Diffusion repo and the 2nd is only accessible via Conduit. I can test that stuff if necessary, but it's such a small change that I'm not worried about it.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8788

Differential Revision: https://secure.phabricator.com/D17718
This commit is contained in:
Austin McKinley 2017-04-18 08:13:34 -07:00
parent 7fd98a5e86
commit b54adc6161
3 changed files with 10 additions and 4 deletions

View file

@ -129,7 +129,7 @@ final class PhabricatorChunkedFileStorageEngine
foreach ($chunks as $chunk) {
$chunk->save();
}
$file->save();
$file->saveAndIndex();
$file->saveTransaction();
return $file;

View file

@ -148,6 +148,12 @@ final class PhabricatorFile extends PhabricatorFileDAO
return parent::save();
}
public function saveAndIndex() {
$this->save();
PhabricatorSearchWorker::queueDocumentForIndexing($this->getPHID());
return $this;
}
public function getMonogram() {
return 'F'.$this->getID();
}
@ -234,7 +240,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
$new_file->readPropertiesFromParameters($params);
$new_file->save();
$new_file->saveAndIndex();
return $new_file;
}
@ -390,7 +396,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
// Do nothing
}
$file->save();
$file->saveAndIndex();
return $file;
}

View file

@ -145,7 +145,7 @@ abstract class PhabricatorFileUploadSource
}
$file = PhabricatorFile::newChunkedFile($engine, $length, $parameters);
$file->save();
$file->saveAndIndex();
$rope = $this->getRope();