mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-14589 filedir location now fully configurable through file storage constructor
This commit is contained in:
parent
18fbaf2e28
commit
744b64ff5d
@ -9,13 +9,8 @@ class file_storage {
|
||||
* Contructor
|
||||
* @param string $filedir full path to pool directory
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
if (isset($CFG->filedir)) {
|
||||
$this->filedir = $CFG->filedir;
|
||||
} else {
|
||||
$this->filedir = $CFG->dataroot.'/filedir';
|
||||
}
|
||||
public function __construct($filedir) {
|
||||
$this->filedir = $filedir;
|
||||
|
||||
// make sure the file pool directory exists
|
||||
if (!is_dir($this->filedir)) {
|
||||
@ -28,6 +23,14 @@ class file_storage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns location of filedir (file pool)
|
||||
* @return string pathname
|
||||
*/
|
||||
public function get_filedir() {
|
||||
return $this->filedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates sha1 hash of unique full path name information
|
||||
* @param int $contextid
|
||||
|
@ -41,12 +41,7 @@ class stored_file {
|
||||
* @return ful path to pool file with file content
|
||||
**/
|
||||
protected function get_content_file_location() {
|
||||
global $CFG;
|
||||
if (isset($CFG->filedir)) {
|
||||
$filedir = $CFG->filedir;
|
||||
} else {
|
||||
$filedir = $CFG->dataroot.'/filedir';
|
||||
}
|
||||
$filedir = $this->fs->get_filedir();
|
||||
$contenthash = $this->file_record->contenthash;
|
||||
$l1 = $contenthash[0].$contenthash[1];
|
||||
$l2 = $contenthash[2].$contenthash[3];
|
||||
|
@ -4502,7 +4502,13 @@ function get_file_storage() {
|
||||
|
||||
require_once("$CFG->libdir/filelib.php");
|
||||
|
||||
$fs = new file_storage();
|
||||
if (isset($CFG->filedir)) {
|
||||
$filedir = $CFG->filedir;
|
||||
} else {
|
||||
$filedir = $CFG->dataroot.'/filedir';
|
||||
}
|
||||
|
||||
$fs = new file_storage($filedir);
|
||||
|
||||
return $fs;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user