mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'wip-MDL-51985-master' of https://github.com/marinaglancy/moodle
This commit is contained in:
commit
b4153ff09d
@ -2196,7 +2196,7 @@ class file_storage {
|
||||
$now = time();
|
||||
foreach ($rs as $record) {
|
||||
$this->update_references($record->id, $now, null,
|
||||
$storedfile->get_contenthash(), $storedfile->get_filesize(), 0);
|
||||
$storedfile->get_contenthash(), $storedfile->get_filesize(), 0, $storedfile->get_timemodified());
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
@ -2414,8 +2414,9 @@ class file_storage {
|
||||
* @param string $contenthash
|
||||
* @param int $filesize
|
||||
* @param int $status 0 if ok or 666 if source is missing
|
||||
* @param int $timemodified last time modified of the source, if known
|
||||
*/
|
||||
public function update_references($referencefileid, $lastsync, $lifetime, $contenthash, $filesize, $status) {
|
||||
public function update_references($referencefileid, $lastsync, $lifetime, $contenthash, $filesize, $status, $timemodified = null) {
|
||||
global $DB;
|
||||
$referencefileid = clean_param($referencefileid, PARAM_INT);
|
||||
$lastsync = clean_param($lastsync, PARAM_INT);
|
||||
@ -2425,9 +2426,10 @@ class file_storage {
|
||||
$params = array('contenthash' => $contenthash,
|
||||
'filesize' => $filesize,
|
||||
'status' => $status,
|
||||
'referencefileid' => $referencefileid);
|
||||
'referencefileid' => $referencefileid,
|
||||
'timemodified' => $timemodified);
|
||||
$DB->execute('UPDATE {files} SET contenthash = :contenthash, filesize = :filesize,
|
||||
status = :status
|
||||
status = :status ' . ($timemodified ? ', timemodified = :timemodified' : '') . '
|
||||
WHERE referencefileid = :referencefileid', $params);
|
||||
$data = array('id' => $referencefileid, 'lastsync' => $lastsync);
|
||||
$DB->update_record('files_reference', (object)$data);
|
||||
|
@ -961,8 +961,9 @@ class stored_file {
|
||||
* @param null|string $contenthash if set to null contenthash is not changed
|
||||
* @param int $filesize new size of the file
|
||||
* @param int $status new status of the file (0 means OK, 666 - source missing)
|
||||
* @param int $timemodified last time modified of the source, if known
|
||||
*/
|
||||
public function set_synchronized($contenthash, $filesize, $status = 0) {
|
||||
public function set_synchronized($contenthash, $filesize, $status = 0, $timemodified = null) {
|
||||
if (!$this->is_external_file()) {
|
||||
return;
|
||||
}
|
||||
@ -974,12 +975,15 @@ class stored_file {
|
||||
$oldcontenthash = $this->file_record->contenthash;
|
||||
}
|
||||
// this will update all entries in {files} that have the same filereference id
|
||||
$this->fs->update_references($this->file_record->referencefileid, $now, null, $contenthash, $filesize, $status);
|
||||
$this->fs->update_references($this->file_record->referencefileid, $now, null, $contenthash, $filesize, $status, $timemodified);
|
||||
// we don't need to call update() for this object, just set the values of changed fields
|
||||
$this->file_record->contenthash = $contenthash;
|
||||
$this->file_record->filesize = $filesize;
|
||||
$this->file_record->status = $status;
|
||||
$this->file_record->referencelastsync = $now;
|
||||
if ($timemodified) {
|
||||
$this->file_record->timemodified = $timemodified;
|
||||
}
|
||||
if (isset($oldcontenthash)) {
|
||||
$this->fs->deleted_file_cleanup($oldcontenthash);
|
||||
}
|
||||
|
@ -375,7 +375,8 @@ class repository_filesystem extends repository {
|
||||
$filesize = filesize($filepath);
|
||||
}
|
||||
$issyncing = false;
|
||||
$file->set_synchronized($contenthash, $filesize);
|
||||
$modified = filemtime($filepath);
|
||||
$file->set_synchronized($contenthash, $filesize, 0, $modified);
|
||||
} else {
|
||||
$file->set_missingsource();
|
||||
}
|
||||
|
@ -2752,7 +2752,7 @@ abstract class repository implements cacheable_object {
|
||||
$params['filename']))) {
|
||||
$file->set_missingsource();
|
||||
} else {
|
||||
$file->set_synchronized($storedfile->get_contenthash(), $storedfile->get_filesize());
|
||||
$file->set_synchronized($storedfile->get_contenthash(), $storedfile->get_filesize(), 0, $storedfile->get_timemodified());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user