From 84876723bb05f1fb87ec0948522aae9b5e54f587 Mon Sep 17 00:00:00 2001 From: Russ Nelson Date: Mon, 23 May 2011 01:18:06 +0000 Subject: [PATCH] Swift needs to rewrite entire files. We need this call to prevent N**2 operations while appending --- includes/filerepo/FileRepo.php | 10 +++++++++- includes/upload/UploadBase.php | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index c4059bf5f2..7fe8e81316 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -429,7 +429,8 @@ abstract class FileRepo { /** - * Append the contents of the source path to the given file. + * Append the contents of the source path to the given file, OR queue + * the appending operation in anticipation of a later appendFinish() call. * @param $srcPath String: location of the source file * @param $toAppendPath String: path to append to. * @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate @@ -438,6 +439,13 @@ abstract class FileRepo { */ abstract function append( $srcPath, $toAppendPath, $flags = 0 ); + /** + * Finish the append operation. + * @param $toAppendPath String: path to append to. + * @return mixed Status or false + */ + abstract function appendFinish( $toAppendPath ); + /** * Remove a temporary file or mark it for garbage collection * @param $virtualUrl String: the virtual URL returned by storeTemp diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index d2db66100a..a8243080b5 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -215,6 +215,19 @@ abstract class UploadBase { return $status; } + /** + * Finish appending to the Repo file + * + * @param $toAppendPath String: path to the Repo file that will be appended to. + * @return Status Status + */ + protected function appendFinish( $toAppendPath ) { + $repo = RepoGroup::singleton()->getLocalRepo(); + $status = $repo->appendFinish( $toAppendPath ); + return $status; + } + + /** * @param $srcPath String: the source path * @return the real path if it was a virtual URL -- 2.20.1