Public Member Functions | |
insert ($key, $sourcePath, $flags=0) | |
Copy a file into the file store from elsewhere in the filesystem. | |
export ($key, $destPath, $flags=0) | |
Copy a file from the file store to elsewhere in the filesystem. | |
delete ($key) | |
Delete a file from the file store. | |
stream ($key) | |
Stream a contained file directly to HTTP output. | |
filePath ($key) | |
Return filesystem path to the given file. | |
urlPath ($key) | |
Return URL path to the given file, if the store is public. | |
Static Public Member Functions | |
static | get ($group) |
Fetch the FileStore object for a given storage group. | |
static | lock () |
Acquire a lock; use when performing write operations on a store. | |
static | unlock () |
Release the global file store lock. | |
static | deleteFile ($path) |
Delete a non-managed file on a transactional basis. | |
static | validKey ($key) |
Confirm that the given file key is valid. | |
static | calculateKey ($path, $extension) |
Calculate file storage key from a file on disk. | |
Public Attributes | |
const | DELETE_ORIGINAL = 1 |
Private Member Functions | |
__construct ($group, $directory, $path, $hash) | |
copyFile ($sourcePath, $destPath, $flags=0) | |
hashPath ($key, $separator) | |
Static Private Member Functions | |
static | lockName () |
Definition at line 6 of file FileStore.php.
FileStore::__construct | ( | $ | group, | |
$ | directory, | |||
$ | path, | |||
$ | hash | |||
) | [private] |
static FileStore::calculateKey | ( | $ | path, | |
$ | extension | |||
) | [static] |
Calculate file storage key from a file on disk.
You must pass an extension to it, as some files may be calculated out of a temporary file etc.
$path | to file | |
$extension |
Definition at line 226 of file FileStore.php.
References $key, $path, wfBaseConvert(), wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().
FileStore::copyFile | ( | $ | sourcePath, | |
$ | destPath, | |||
$ | flags = 0 | |||
) | [private] |
Definition at line 92 of file FileStore.php.
References $flags, $ok, FSTransaction::DELETE_FILE, wfDebug(), wfMkdirParents(), wfRestoreWarnings(), and wfSuppressWarnings().
FileStore::delete | ( | $ | key | ) |
Delete a file from the file store.
Caller's responsibility to make sure it's not being used by another row.
File is not actually removed until transaction commit. Should be protected by FileStore::lock() to avoid race conditions.
$key | storage key string |
FSException | if file can't be deleted |
Definition at line 145 of file FileStore.php.
References $key, deleteFile(), and filePath().
static FileStore::deleteFile | ( | $ | path | ) | [static] |
Delete a non-managed file on a transactional basis.
File is not actually removed until transaction commit. Should be protected by FileStore::lock() to avoid race conditions.
$path | file to remove |
FSException | if file can't be deleted |
Definition at line 166 of file FileStore.php.
References $path, and FSTransaction::DELETE_FILE.
Referenced by delete().
FileStore::export | ( | $ | key, | |
$ | destPath, | |||
$ | flags = 0 | |||
) |
Copy a file from the file store to elsewhere in the filesystem.
Should be protected by FileStore::lock() to avoid race conditions.
$key | storage key string | |
$flags | DELETE_ORIGINAL - remove the source file on transaction commit. |
FSException | if copy can't be completed |
Definition at line 87 of file FileStore.php.
References $flags, $key, copyFile(), and filePath().
FileStore::filePath | ( | $ | key | ) |
Return filesystem path to the given file.
Note that the file may or may not exist.
Definition at line 256 of file FileStore.php.
References $key, and hashPath().
static FileStore::get | ( | $ | group | ) | [static] |
Fetch the FileStore object for a given storage group.
Definition at line 12 of file FileStore.php.
References $wgFileStore.
Referenced by DeleteArchivedFiles(), RevisionDeleter::makeOldImagePrivate(), RevisionDeleter::makeOldImagePublic(), UndeleteForm::showFile(), and SpecialRevisionDelete::showFile().
FileStore::hashPath | ( | $ | key, | |
$ | separator | |||
) | [private] |
FileStore::insert | ( | $ | key, | |
$ | sourcePath, | |||
$ | flags = 0 | |||
) |
Copy a file into the file store from elsewhere in the filesystem.
Should be protected by FileStore::lock() to avoid race conditions.
$key | storage key string | |
$flags | DELETE_ORIGINAL - remove the source file on transaction commit. |
FSException | if copy can't be completed |
Definition at line 71 of file FileStore.php.
References $flags, $key, copyFile(), and filePath().
static FileStore::lock | ( | ) | [static] |
Acquire a lock; use when performing write operations on a store.
This is attached to your master database connection, so if you suffer an uncaught error the lock will be released when the connection is closed.
Definition at line 40 of file FileStore.php.
References $dbw, lockName(), and wfGetDB().
Referenced by DeleteArchivedFiles(), RevisionDeleter::makeOldImagePrivate(), and RevisionDeleter::makeOldImagePublic().
static FileStore::lockName | ( | ) | [static, private] |
FileStore::stream | ( | $ | key | ) |
Stream a contained file directly to HTTP output.
Will throw a 404 if file is missing; 400 if invalid key.
Definition at line 181 of file FileStore.php.
References $key, $path, filePath(), wfHttpError(), and wfStreamFile().
static FileStore::unlock | ( | ) | [static] |
Release the global file store lock.
Definition at line 50 of file FileStore.php.
References $dbw, lockName(), and wfGetDB().
Referenced by RevisionDeleter::makeOldImagePrivate(), and RevisionDeleter::makeOldImagePublic().
FileStore::urlPath | ( | $ | key | ) |
Return URL path to the given file, if the store is public.
Definition at line 269 of file FileStore.php.
References $key, and hashPath().
static FileStore::validKey | ( | $ | key | ) | [static] |
Confirm that the given file key is valid.
Note that a valid key may refer to a file that does not exist.
Key should consist of a 31-digit base-36 SHA-1 hash and an optional alphanumeric extension, all lowercase. The whole must not exceed 64 characters.
$key |
Definition at line 212 of file FileStore.php.
References $key.
const FileStore::DELETE_ORIGINAL = 1 |
Definition at line 7 of file FileStore.php.
Referenced by RevisionDeleter::makeOldImagePrivate(), and RevisionDeleter::makeOldImagePublic().