From 580fa92393538255f08dd857a766cdb8e262c948 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 19 Nov 2025 20:31:24 +0100 Subject: [PATCH] set the original file name will other adjust the file type --- op/op.Ajax.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index e0e73c539..53435eee6 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -694,20 +694,28 @@ switch($command) { $document = $content->getDocument(); if ($document->getAccessMode($user) >= M_READWRITE) { $oldname = $content->getOriginalFileName(); - if (!$content->setOriginalFilename($_REQUEST['name'])) { - header('Content-Type: application/json'); - echo json_encode(array('success'=>false, 'message'=>'Error setting original file name', 'data'=>'')); - } else { - if($fulltextservice && ($index = $fulltextservice->Indexer())) { - $lucenesearch = $fulltextservice->Search(); - if($hit = $lucenesearch->getDocument($document->getId())) { - $index->reindexDocument($hit->id); - $index->commit(); + $newname = trim($_REQUEST['name']); + if ($oldname != $newname) { + if (!$content->setOriginalFilename($newname)) { + header('Content-Type: application/json'); + echo json_encode(array('success'=>false, 'message'=>'Error setting original file name', 'data'=>'')); + } else { + $fileType = pathinfo($newname, PATHINFO_EXTENSION); + $content->setFileType($fileType); + if($fulltextservice && ($index = $fulltextservice->Indexer())) { + $lucenesearch = $fulltextservice->Search(); + if($hit = $lucenesearch->getDocument($document->getId())) { + $index->reindexDocument($hit->id); + $index->commit(); + } } + header('Content-Type: application/json'); + echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_changed'), 'data'=>'')); + add_log_line("set original filename '".$_REQUEST['name']."' of document ".$document->getId().":".$content->getVersion()); } + } else { header('Content-Type: application/json'); - echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_changed'), 'data'=>'')); - add_log_line("set original filename '".$_REQUEST['name']."' of document ".$document->getId().":".$content->getVersion()); + echo json_encode(array('success'=>true, 'message'=>getMLText('splash_orig_filename_unchanged'), 'data'=>'')); } } else { header('Content-Type: application/json');