[FileRepo] Various code cleanups.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Apr 2012 04:10:50 +0000 (21:10 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Apr 2012 19:48:47 +0000 (12:48 -0700)
commitc8e1463cc031791151af40d7e2909d41bf56258c
tree730b1e799d53d8a0a1ba88c01a91cd0f6298e26e
parent3f6312b1daebbdc8c4f121110b1618eaf69856dc
[FileRepo] Various code cleanups.

* Made File::isHashed() wrap FileRepo::getHashLevels(). Removed now-used FileRepo::isHashed().
* Removed FileRepo::simpleClean(). Not useful anymore since the paths in Status errors don't have $IP or upload dirs anymore.
* Removed code in FileRepo::fileExistsBatch() and FileRepo::cleanupBatch() to handle FS file paths, which should never be passed in anymore. Likewise, removed FILES_ONLY parameter.
* Removed FileRepo::append()/appendFinish() stub functions.
* Added FileRepo::assertWritableRepo() function to better handle repos that are read-only by design rather than the hack of overwriting each function (several were missed).
* Added FileBackend::isPathTraversalFree() function and used it in FileRepo::validateFilename() to avoid duplication.
* Tweaked FileRepo::freeTemp() to avoid file locking and made FileRepo::cleanupBatch() return a Status.
* Moved FileRepo::cleanupDeletedBatch() near FileRepo::deleteBatch().
* Added type hinting to a few places.
* Tweaked some misleading doc comments and added function visibility markers.

Change 1:
* Simplified NullRepo to also use assertWritableRepo(). It is currently only used by a single unit test.

Change-Id: I1cd0f4971011772e38e5156f94ffc50325372f28
includes/filerepo/FileRepo.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/ForeignDBRepo.php
includes/filerepo/ForeignDBViaLBRepo.php
includes/filerepo/LocalRepo.php
includes/filerepo/NullRepo.php
includes/filerepo/backend/FileBackend.php
includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/upload/UploadStash.php