Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/Controller/FileHandlingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public function save($path, $filecontents, $mtime) {
}

if($file->isUpdateable()) {
if (empty($mtime)) {
$this->logger->error('Save request without the modification time of the loaded file: ' . $path, ['app' => 'files_mindmap']);
return new DataResponse(['message' => $this->l->t('The mind map could not be saved. Please reload it and try again.')], Http::STATUS_BAD_REQUEST);
}
if ($mtime != $file->getMTime()) {
$this->logger->error("User cannot save shared mind map (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']);
return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST);
Expand All @@ -159,24 +163,21 @@ public function save($path, $filecontents, $mtime) {
} else {
// Not writeable!
$this->logger->error('User does not have permission to write to file: ' . $path,
['app' => 'files_texteditor']);
['app' => 'files_mindmap']);
return new DataResponse([ 'message' => $this->l->t('Insufficient permissions')],
Http::STATUS_BAD_REQUEST);
}
} else if ($path === '') {
} else {
$this->logger->error('No file path supplied');
return new DataResponse(['message' => $this->l->t('File path not supplied')], Http::STATUS_BAD_REQUEST);
} else {
$this->logger->error('No file mtime supplied', ['app' => 'files_texteditor']);
return new DataResponse(['message' => $this->l->t('File mtime not supplied')], Http::STATUS_BAD_REQUEST);
}

} catch (HintException $e) {
$message = (string)$e->getHint();
return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
} catch (\Exception $e) {
$message = (string)$this->l->t('An internal server error occurred.');
$message = $path;
$this->logger->error('Could not save mind map: ' . $path, ['app' => 'files_mindmap', 'exception' => $e]);
$message = (string)$this->l->t('The mind map could not be saved. Please try again later.');
return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/PublicFileHandlingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ public function save($token, $filecontents, $path, $mtime) {
}

if(($file instanceof File) && $file->isUpdateable()) {
if (empty($mtime)) {
$this->logger->error('Save request without the modification time of the loaded file: ' . $file->getPath(), ['app' => 'files_mindmap']);
return new DataResponse(['message' => $this->l->t('The mind map could not be saved. Please reload it and try again.')], Http::STATUS_BAD_REQUEST);
}
if ($mtime != $file->getMTime()) {
$this->logger->error("Anonymous cannot save shared mind map (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']);
return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST);
Expand Down