Skip to content

Commit 057c0dc

Browse files
Merge pull request #55564 from nextcloud/fix/files/return-valid-mimetype
2 parents dc76815 + 8d8f94b commit 057c0dc

File tree

9 files changed

+17
-20
lines changed

9 files changed

+17
-20
lines changed

apps/files_trashbin/lib/Trash/TrashItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getPath() {
7070
return $this->fileInfo->getPath();
7171
}
7272

73-
public function getMimetype() {
73+
public function getMimetype(): string {
7474
return $this->fileInfo->getMimetype();
7575
}
7676

lib/private/Files/Cache/CacheEntry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public function getName() {
6565
}
6666

6767

68-
public function getMimeType() {
69-
return $this->data['mimetype'];
68+
public function getMimeType(): string {
69+
return $this->data['mimetype'] ?? 'application/octet-stream';
7070
}
7171

7272

lib/private/Files/FileInfo.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ public function getId() {
133133
return isset($this->data['fileid']) ? (int)$this->data['fileid'] : null;
134134
}
135135

136-
/**
137-
* @return string
138-
*/
139-
public function getMimetype() {
140-
return $this->data['mimetype'];
136+
public function getMimetype(): string {
137+
return $this->data['mimetype'] ?? 'application/octet-stream';
141138
}
142139

143140
/**

lib/private/Files/Node/LazyFolder.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,7 @@ public function getUserFolder($userId) {
314314
return $this->__call(__FUNCTION__, func_get_args());
315315
}
316316

317-
/**
318-
* @inheritDoc
319-
*/
320-
public function getMimetype() {
317+
public function getMimetype(): string {
321318
if (isset($this->data['mimetype'])) {
322319
return $this->data['mimetype'];
323320
}

lib/private/Files/Node/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function isShared() {
339339
return $this->getFileInfo(false)->isShared();
340340
}
341341

342-
public function getMimeType() {
342+
public function getMimeType(): string {
343343
return $this->getFileInfo(false)->getMimetype();
344344
}
345345

lib/private/Files/Node/NonExistingFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function putContent($data) {
122122
throw new NotFoundException();
123123
}
124124

125-
public function getMimeType() {
125+
public function getMimeType(): string {
126126
if ($this->fileInfo) {
127127
return parent::getMimeType();
128128
} else {

lib/public/Files/Cache/ICacheEntry.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace OCP\Files\Cache;
99

1010
use ArrayAccess;
11+
use OCP\AppFramework\Attribute\Consumable;
1112

1213
/**
1314
* meta data for a file or folder
@@ -19,6 +20,7 @@
1920
* implemented it in the private implementation. Hence php would allow using the
2021
* object as array, while strictly speaking it didn't support this.
2122
*/
23+
#[Consumable(since: '9.0.0')]
2224
interface ICacheEntry extends ArrayAccess {
2325
/**
2426
* @since 9.0.0
@@ -60,10 +62,9 @@ public function getName();
6062
/**
6163
* Get the full mimetype
6264
*
63-
* @return string
6465
* @since 9.0.0
6566
*/
66-
public function getMimeType();
67+
public function getMimeType(): string;
6768

6869
/**
6970
* Get the first part of the mimetype

lib/public/Files/File.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
namespace OCP\Files;
1212

13+
use OCP\AppFramework\Attribute\Consumable;
1314
use OCP\Lock\LockedException;
1415

1516
/**
1617
* Interface File
1718
*
1819
* @since 6.0.0
1920
*/
21+
#[Consumable(since: '6.0.0')]
2022
interface File extends Node {
2123
/**
2224
* Get the content of the file as string
@@ -43,10 +45,9 @@ public function putContent($data);
4345
/**
4446
* Get the mimetype of the file
4547
*
46-
* @return string
4748
* @since 6.0.0
4849
*/
49-
public function getMimeType();
50+
public function getMimeType(): string;
5051

5152
/**
5253
* Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen

lib/public/Files/FileInfo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
*/
88
namespace OCP\Files;
99

10+
use OCP\AppFramework\Attribute\Consumable;
1011
use OCP\Files\Storage\IStorage;
1112

1213
/**
1314
* Interface FileInfo
1415
*
1516
* @since 7.0.0
1617
*/
18+
#[Consumable(since: '7.0.0')]
1719
interface FileInfo {
1820
/**
1921
* @since 7.0.0
@@ -103,10 +105,9 @@ public function getPath();
103105
/**
104106
* Get the full mimetype of the file or folder i.e. 'image/png'
105107
*
106-
* @return string
107108
* @since 7.0.0
108109
*/
109-
public function getMimetype();
110+
public function getMimetype(): string;
110111

111112
/**
112113
* Get the first part of the mimetype of the file or folder i.e. 'image'

0 commit comments

Comments
 (0)