From 8ac72824e12ea90a15da3f79b5d559c4de827ec8 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 29 Apr 2015 10:09:03 +0800 Subject: [PATCH] MDL-49995 files: delete old file when overwriting --- lib/filestorage/stored_file.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/filestorage/stored_file.php b/lib/filestorage/stored_file.php index e1c3e738d09..aec547d3cfe 100644 --- a/lib/filestorage/stored_file.php +++ b/lib/filestorage/stored_file.php @@ -297,7 +297,9 @@ class stored_file { $filerecord->filesize = $newfile->get_filesize(); $filerecord->referencefileid = $newfile->get_referencefileid(); $filerecord->userid = $newfile->get_userid(); + $oldcontenthash = $this->get_contenthash(); $this->update($filerecord); + $this->filesystem->remove_file($oldcontenthash); } /**