Fix for "disappearing" media files after renaming.
The renaming code added a dot '.' to the filename on disk even if the file hat no extension. Therefore, the file name on disk was different from the name in the database, triggering the database purging code on the next ML display. (serendipity_displayImageList() will delete files from the database that don't exist any longer on disk.) This code won't add spurious dots for empty extensions, keeping disk and database in sync. Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
@ -2259,7 +2259,7 @@ function serendipity_renameFile($id, $newName, $path = null) {
|
||||
$newName = serendipity_uploadSecure(serendipity_makeFilename($newName), true);
|
||||
$imgBase = $serendipity['serendipityPath'] . $serendipity['uploadPath'];
|
||||
|
||||
$newPath = "{$imgBase}{$path}{$newName}.{$file['extension']}";
|
||||
$newPath = $imgBase . $path . $newName . (empty($File['extension']) ? '' : '.' . $File['extension']);
|
||||
|
||||
if (file_exists($newPath)) {
|
||||
return sprintf('<span class="msg_error"><span class="icon-attention-circled" aria-hidden="true"></span> ' . ERROR_FILE_EXISTS . "</span>\n", $newName);
|
||||
@ -2268,9 +2268,9 @@ function serendipity_renameFile($id, $newName, $path = null) {
|
||||
if (rename("{$imgBase}{$file['path']}{$file['realname']}", $newPath)) {
|
||||
# if renaming was successfull, rename thumbnails and update
|
||||
# databases and entries
|
||||
|
||||
|
||||
serendipity_renameThumbnails($id, "{$path}$newName");
|
||||
|
||||
|
||||
serendipity_updateImageInDatabase(array('name' => $newName, 'realname' => basename($newPath)), $id);
|
||||
serendipity_updateImageInEntries($id, $file);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user