Skip to content

Commit

Permalink
fix: Properly create new files on public share links
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <[email protected]>
  • Loading branch information
juliusknorr committed Sep 20, 2024
1 parent b5e9d70 commit 25bf7e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,13 @@ public function publicPage($shareToken, $fileName, $fileId) {
} else {
$item = $node;
}

if ($item instanceof Node) {
// Public pages on older versions somehow create 1 byte files, this is a workaround to have a proper file content for new files
if ($item->getSize() === 1) {
$item->putContent(file_get_contents(__DIR__ . '/../../assets/template.' . $item->getExtension()));
}

$params = [
'permissions' => $share->getPermissions(),
'title' => $item->getName(),
Expand Down
2 changes: 1 addition & 1 deletion lib/WOPI/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function getUrlSrcForFile(File $file, bool $edit): string {
}

$actions = [
$edit && $file->getSize() === 0 ? self::ACTION_EDITNEW : null,
$edit && ($file->getSize() === 0 || $file->getSize() === 1) ? self::ACTION_EDITNEW : null,
$edit ? self::ACTION_EDIT : null,
self::ACTION_VIEW,
];
Expand Down

0 comments on commit 25bf7e7

Please sign in to comment.