Preselect "Hide Download" for external shares

Hi everyone!
I installed nextcloud on our shared server and updated today to the actual version.
Nextcloud: 19.0.2.
PHP: 7.3

I would like to have the option “Hide Download” activated automatically for every new external share. I didn’t find anything in the documentation, google or this forum.

Does anyone know a way to archive this?

Thanks a lot!
Nils

Hey everyone!

Just wanted to “update” this topic.
Does anyone have an idea how i could realize this?

Thanks a lot!
Nils

I think you must modify the source code.

Perhaps someone could post the position in the code for activating the public share.
Search for positions: https://github.com/nextcloud/server/search?q=setHideDownload

Perhaps “private function createShare($data) {”
https://github.com/nextcloud/server/blob/stable19/lib/private/Share20/DefaultShareProvider.php
(line 1007 -> line 1056)

Before sharing you must set it to “true”. Perhaps you can check for external shares and modify to “true” only for external shares.

$share->setHideDownload(true);
$share->setHideDownload(1);

relevant code in Share.php for shares:

    public function setHideDownload(bool $hide): IShare {
		$this->hideDownload = $hide;
		return $this;
	}

	public function getHideDownload(): bool {
		return $this->hideDownload;
	}

https://github.com/nextcloud/server/blob/stable19/lib/private/Share20/Share.php
(at the end of the code)

Hey devnull!
Thank you very much for your answer!

Because of your post i came to the idea to change it in the database.
The table “*_share” has the column “hide_download” with a default of “0”.
I just changed the default to “1” and it works like a charm.

I don’t know how it will be affected after updates but i will check this.

Does ist really work with new shares?

It does!
It is the default value in the table structure.
So, if there is a new entry it is not filled from the source code, it is filled from this default value.

1 Like

I have a new information about that.
The change in the database was good for links i created to share files and folders but when i tried to share via an e-mail address it didn´t work.
To solve this problem i changed line 101 in lib/private/Share20/Share.php
private $hideDownload = true;
That doesn´t solve the problem for both cases but with the database change it works perfectly for now.